From 07fcd8be73034c2c940fc6e43a894f5231e72b17 Mon Sep 17 00:00:00 2001 From: scanash00 Date: Fri, 12 Jun 2026 11:52:39 -0800 Subject: [PATCH] Fix Spacedust WebSocket: don't request an unnegotiated subprotocol The client passed a User-Agent-derived string as a WebSocket subprotocol for attribution, but Spacedust doesn't negotiate one. When a client requests a subprotocol the server doesn't echo back, the handshake fails ('Server sent no subprotocol') - which is why every live-notifications connection dropped. Verified live: connecting with no subprotocol opens fine; with the subprotocol it errors. Removed it - real-time like/repost/reply/follow notifications now connect. --- src/lib/microcosm/spacedust.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib/microcosm/spacedust.ts b/src/lib/microcosm/spacedust.ts index 002796c..2fcecb0 100644 --- a/src/lib/microcosm/spacedust.ts +++ b/src/lib/microcosm/spacedust.ts @@ -6,7 +6,7 @@ * * @see spacedust.json at the repo root */ -import {MICROCOSM_USER_AGENT, SPACEDUST_URL} from '#/env' +import {SPACEDUST_URL} from '#/env' export type SpacedustSubscription = { /** Link sources to receive, e.g. `app.bsky.feed.like:subject.uri`. */ @@ -75,17 +75,16 @@ function buildUrl(sub: SpacedustSubscription): string { /** * Open a Spacedust subscription. Returns a handle with `.close()`. * - * Note: `User-Agent` can't be set on a browser WebSocket; it's encoded into the - * protocol field where supported so microcosm can still attribute the client. + * Note: do NOT request a WebSocket subprotocol. Spacedust doesn't negotiate one, + * and if the client asks for a subprotocol the server doesn't echo back, the + * handshake fails ("Server sent no subprotocol"). `User-Agent` can't be set on a + * browser WebSocket, so the client is simply not attributed here. */ export function subscribe( sub: SpacedustSubscription, handlers: SpacedustHandlers, ): {close: () => void} { - const ws = new WebSocket(buildUrl(sub), [ - // best-effort attribution; ignored by servers that don't negotiate it - MICROCOSM_USER_AGENT.replace(/[^\w.-]/g, '_'), - ]) + const ws = new WebSocket(buildUrl(sub)) ws.onopen = () => handlers.onOpen?.() ws.onerror = e => handlers.onError?.(e) -- 2.51.2