diff --git a/src/lib/microcosm/spacedust.ts b/src/lib/microcosm/spacedust.ts --- 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 @@ /** * 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)