@caprid/relay-websocket 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,18 +1,16 @@
1
1
  # @caprid/relay-websocket
2
2
 
3
3
  The Relay SDK's transport adapter for QMux over WebSocket. It carries MOQT on
4
- [QMux](https://datatracker.ietf.org/doc/draft-ietf-quic-qmux/) (QUIC's streams over a reliable byte stream, wire
5
- format `qmux-01`) inside one WebSocket connection, the way moq-relay serves it on TCP 443
6
- ([draft-lcurley-qmux-websocket](https://github.com/moq-dev/moq/blob/main/drafts/draft-lcurley-qmux-websocket.md)). It
7
- reaches the relay where WebTransport cannot: networks that block UDP, and browsers without a WebTransport that can
8
- negotiate protocols. It works in browsers and in Node 24.
4
+ [QMux](https://datatracker.ietf.org/doc/draft-ietf-quic-qmux/), which runs QUIC's streams over a reliable byte stream
5
+ (wire format `qmux-01`), inside one WebSocket connection. moq-relay serves it on TCP 443
6
+ ([draft-lcurley-qmux-websocket](https://github.com/moq-dev/moq/blob/main/drafts/draft-lcurley-qmux-websocket.md)). The
7
+ adapter reaches the relay where WebTransport cannot: on networks that block UDP, and in browsers whose WebTransport
8
+ cannot negotiate protocols. It works in browsers and in Node 24.
9
9
 
10
- It follows the transport adapter contract in [`spec/transport-adapter.md`](../../../spec/transport-adapter.md), with
10
+ It follows the transport adapter contract in [`spec/transport-adapter.md`](https://github.com/caprids/relay-sdks/blob/main/spec/transport-adapter.md), with
11
11
  the deviations recorded there, and passes its conformance suite in Node, Chromium, Firefox and WebKit. QMux comes from
12
12
  [`@moq/qmux`](https://www.npmjs.com/package/@moq/qmux), by the author of moq-relay's own QMux, at an exact version;
13
- [ADR 0005](../../../docs/adr/0005-websocket-adapter-wraps-moq-qmux.md) records why.
14
-
15
- The package is unpublished, like the rest of the SDK.
13
+ [ADR 0005](https://github.com/caprids/relay-sdks/blob/main/docs/adr/0005-websocket-adapter-wraps-moq-qmux.md) records why.
16
14
 
17
15
  ## Use
18
16
 
@@ -22,31 +20,33 @@ Pass one of its factories as the SDK's `createTransport`. Build it once and reus
22
20
  import { connectRelaySubscriber } from '@caprid/relay';
23
21
  import { createWebSocketTransport, withWebSocketFallback } from '@caprid/relay-websocket';
24
22
 
25
- // WebTransport first; WebSocket when its handshake fails or takes longer than 4 s.
23
+ // WebTransport first; WebSocket races it once WebTransport has had 250 ms.
26
24
  const subscriber = await connectRelaySubscriber({ url, getToken, createTransport: withWebSocketFallback() });
27
25
 
28
26
  // Always WebSocket.
29
27
  const other = await connectRelaySubscriber({ url, getToken, createTransport: createWebSocketTransport() });
30
28
  ```
31
29
 
32
- - `createWebSocketTransport()` dials the endpoint's `wss:` URL (`https:` becomes `wss:`, path and query unchanged, so
33
- the token travels in the upgrade request), offering `qmux-01.moqt-22`, then `qmux-01.moqt-20`. Its factory declares
34
- `framing: 'websocket'`.
35
- - `withWebSocketFallback({ handshakeTimeoutMs, onFallback })` dials the runtime's `WebTransport`, and falls back to
36
- WebSocket when that handshake fails or has not completed within `handshakeTimeoutMs` (default 4000). Where the runtime
37
- has no usable `WebTransport` (Node, Safari without it) it dials WebSocket at once. `onFallback(reason)` is told each
38
- time a connection falls back. The dials run one after the other, and every connection decides afresh. The factory's
39
- `framing` and the transport's `carrier` say which transport is in use.
30
+ - `createWebSocketTransport()` dials the endpoint's `wss:` URL and offers `qmux-01.moqt-22`, then `qmux-01.moqt-20`.
31
+ `https:` becomes `wss:` with the path and query unchanged, so the token travels in the upgrade request. The factory
32
+ declares `framing: 'websocket'`.
33
+ - `withWebSocketFallback({ webSocketDelayMs, onFallback })` dials the runtime's `WebTransport` first. If that
34
+ handshake has not completed within `webSocketDelayMs` (default 250, as Happy Eyeballs), it dials WebSocket alongside
35
+ it; a WebTransport handshake that fails sooner starts the WebSocket at once. The first ready carries the session and
36
+ the other dial is closed. Where the runtime has no usable `WebTransport`, as in Node or a Safari without it, it dials
37
+ WebSocket at once. The adapter calls `onFallback(reason)` each time a connection ends up on WebSocket, and every
38
+ connection decides afresh. After `ready`, the factory's `framing` and the transport's `carrier` say which transport
39
+ won.
40
40
 
41
41
  ## What differs from WebTransport
42
42
 
43
- - Every stream shares one TCP connection: a lost packet holds up every stream behind it (head-of-line blocking).
43
+ - Every stream shares one TCP connection, so a lost packet holds up every stream behind it (head-of-line blocking).
44
44
  - No datagrams.
45
45
  - A relay that refuses the token answers the WebSocket upgrade with HTTP 401, which no WebSocket API exposes, so the
46
46
  SDK reports `TRANSPORT_ERROR` in phase `connecting`, not `UNAUTHORIZED`.
47
47
  - A send stream's close resolves once the FIN is handed to the socket, not once the relay has it.
48
48
 
49
- The relay's side, with measurements, is in [QMux over WebSocket](../../../spec/relay-interop.md#qmux-over-websocket).
49
+ The relay's side, with measurements, is in [QMux over WebSocket](https://github.com/caprids/relay-sdks/blob/main/spec/relay-interop.md#qmux-over-websocket).
50
50
 
51
51
  ## Trust
52
52
 
@@ -55,13 +55,16 @@ certificate. Node trusts the platform's roots, plus any in `NODE_EXTRA_CA_CERTS`
55
55
 
56
56
  ## Tests
57
57
 
58
+ Run these from `ts/` in the repository.
59
+
58
60
  - `pnpm test` runs the unit tests in `src/tests/` against an in-process accepting end over plain `ws://`.
59
61
  - `pnpm test:conformance:websocket` runs the conformance suite in Node against `scripts/websocket-peer.js`, the
60
- accepting end for QMux over WebSocket; `pnpm test:conformance:websocket:browsers` runs it in Chromium, Firefox and
61
- WebKit (`BROWSERS=chromium` for one).
62
+ accepting end for QMux over WebSocket.
63
+ - `pnpm test:conformance:websocket:browsers` runs the suite in Chromium, Firefox, and WebKit. Set `BROWSERS=chromium`
64
+ to run one.
62
65
  - `RELAY_RUNTIME=node-websocket,chromium-websocket pnpm test:relay` runs the live scenario over WebSocket.
63
66
 
64
67
  ## Stability
65
68
 
66
69
  Before 1.0, a minor version can break the API. This package releases together with `@caprid/relay` at the same version;
67
- see the [changelog](../../CHANGELOG.md).
70
+ see the [changelog](https://github.com/caprids/relay-sdks/blob/main/ts/CHANGELOG.md).
@@ -1,6 +1,6 @@
1
1
  /**
2
- * WebTransport first, then QMux over WebSocket: the fallback policy (spec/behavior.md, "Transport fallback"). One
3
- * transport stands for whichever dial wins, so the SDK's connect call sees a single factory.
2
+ * WebTransport first, then QMux over WebSocket racing it: the fallback policy (spec/behavior.md, "Transport
3
+ * fallback"). One transport stands for whichever dial wins, so the SDK's connect call sees a single factory.
4
4
  */
5
5
  import type { BidirectionalStreamLike, MoqtSendStreamOptions, MoqtTransport } from '@caprid/moq-core';
6
6
  import { type CloseInfo } from './errors.js';
@@ -9,23 +9,28 @@ export type FallbackCarrier = 'webtransport' | 'websocket';
9
9
  /** Options for {@link withWebSocketFallback}. */
10
10
  export interface WebSocketFallbackOptions {
11
11
  /**
12
- * How long the WebTransport handshake may take before the dial gives up on it and opens a WebSocket instead, in
13
- * milliseconds. Default 4000: Chromium itself gives up on an unanswered handshake after about 4 seconds. Keep it
14
- * well inside the connection's `connectTimeoutMs`, which covers both handshakes and SETUP.
12
+ * The WebTransport dial's head start, in milliseconds: if its handshake has not completed by then, the WebSocket dial
13
+ * starts too and the first to be ready carries the session. Default 250, the Connection Attempt Delay of Happy
14
+ * Eyeballs (RFC 8305). 0 starts both dials at once. A WebTransport handshake that fails sooner starts the WebSocket
15
+ * dial straight away.
15
16
  */
16
- handshakeTimeoutMs?: number;
17
+ webSocketDelayMs?: number;
17
18
  /**
18
- * Called once when a dial falls back to WebSocket, with why WebTransport was not used: its handshake failed or timed
19
- * out (the error), or the runtime has no usable `WebTransport` (`undefined`). For logging; it cannot stop the
20
- * fallback.
19
+ * Called once when a connection ends up on WebSocket, with why WebTransport was not used: its handshake failed, the
20
+ * WebSocket was ready first (both an error), or the runtime has no usable `WebTransport` (`undefined`). For logging;
21
+ * it cannot change the outcome.
21
22
  */
22
23
  onFallback?: (reason: unknown) => void;
23
24
  }
24
- /** The handshake timeout `value` gives, 4 s when it is undefined; a TypeError or RangeError for one a timer cannot hold. */
25
- export declare function assertHandshakeTimeout(value: unknown): number;
26
25
  /**
27
- * A transport that dials WebTransport and falls back to QMux over WebSocket when that handshake fails or takes longer
28
- * than the timeout. Before `ready` it stands in for whichever dial is in progress; after, it is the winner's.
26
+ * The WebSocket delay the options give, 250 ms when unset; a TypeError or RangeError for one a timer cannot hold, or
27
+ * for `handshakeTimeoutMs`, which it replaced.
28
+ */
29
+ export declare function assertFallbackOptions(options: WebSocketFallbackOptions): number;
30
+ /**
31
+ * A transport that dials WebTransport and, unless that is ready within the WebSocket delay, QMux over WebSocket
32
+ * alongside it: the first ready carries the session and the other is closed. Before `ready` it stands in for the dials
33
+ * in progress; after, it is the winner's.
29
34
  */
30
35
  export declare class FallbackTransport implements MoqtTransport {
31
36
  #private;
@@ -38,13 +43,13 @@ export declare class FallbackTransport implements MoqtTransport {
38
43
  /** The winner's incoming bidirectional streams. */
39
44
  readonly incomingBidirectionalStreams: ReadableStream<BidirectionalStreamLike>;
40
45
  constructor(url: string, protocols: readonly string[], options?: WebSocketFallbackOptions);
41
- /** The transport the session runs on: the one in progress before `ready`, the winner after. */
46
+ /** The transport the session runs on; undefined until `ready`. */
42
47
  get carrier(): FallbackCarrier | undefined;
43
48
  /** The protocol the winner's peer selected (TA-8); empty until `ready` resolves. */
44
49
  get protocol(): string;
45
50
  createUnidirectionalStream(options?: MoqtSendStreamOptions): Promise<WritableStream<Uint8Array>>;
46
51
  createBidirectionalStream(): Promise<BidirectionalStreamLike>;
47
- /** Close the winner (TA-10); before `ready`, cancel whichever dial is in progress (TA-11). */
52
+ /** Close the winner (TA-10); before `ready`, cancel every dial in progress (TA-11). */
48
53
  close(info?: {
49
54
  closeCode?: number;
50
55
  reason?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../src/fallback.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtG,OAAO,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MAAM,CAErB;IAEK,0BAA0B,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAIhG,yBAAyB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAInE,uFAAuF;IACvF,KAAK,CAAC,IAAI,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,IAAI;CAiKhE;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYlD"}
package/dist/fallback.js CHANGED
@@ -6,22 +6,37 @@ function usableWebTransport() {
6
6
  return undefined;
7
7
  return 'protocol' in WebTransport.prototype ? WebTransport : undefined;
8
8
  }
9
- /** The handshake timeout `value` gives, 4 s when it is undefined; a TypeError or RangeError for one a timer cannot hold. */
10
- export function assertHandshakeTimeout(value) {
9
+ /**
10
+ * The WebSocket delay the options give, 250 ms when unset; a TypeError or RangeError for one a timer cannot hold, or
11
+ * for `handshakeTimeoutMs`, which it replaced.
12
+ */
13
+ export function assertFallbackOptions(options) {
14
+ if ('handshakeTimeoutMs' in options)
15
+ throw new TypeError('handshakeTimeoutMs was replaced by webSocketDelayMs: the WebSocket dial now races WebTransport');
16
+ const value = options.webSocketDelayMs;
11
17
  if (value === undefined)
12
- return 4_000;
18
+ return 250;
13
19
  if (typeof value !== 'number')
14
- throw new TypeError('handshakeTimeoutMs must be a number of milliseconds');
15
- if (!Number.isFinite(value) || value <= 0 || value > 2_147_483_647)
16
- throw new RangeError('handshakeTimeoutMs must be between 0 (exclusive) and 2147483647 milliseconds');
20
+ throw new TypeError('webSocketDelayMs must be a number of milliseconds');
21
+ if (!Number.isFinite(value) || value < 0 || value > 2_147_483_647)
22
+ throw new RangeError('webSocketDelayMs must be between 0 and 2147483647 milliseconds');
17
23
  return value;
18
24
  }
19
- class HandshakeTimeout extends Error {
20
- name = 'HandshakeTimeout';
25
+ class WebTransportOutpaced extends Error {
26
+ name = 'WebTransportOutpaced';
27
+ }
28
+ function closeQuietly(transport, info) {
29
+ try {
30
+ transport.close(info);
31
+ }
32
+ catch {
33
+ // A failed handshake may leave a transport that already refuses close().
34
+ }
21
35
  }
22
36
  /**
23
- * A transport that dials WebTransport and falls back to QMux over WebSocket when that handshake fails or takes longer
24
- * than the timeout. Before `ready` it stands in for whichever dial is in progress; after, it is the winner's.
37
+ * A transport that dials WebTransport and, unless that is ready within the WebSocket delay, QMux over WebSocket
38
+ * alongside it: the first ready carries the session and the other is closed. Before `ready` it stands in for the dials
39
+ * in progress; after, it is the winner's.
25
40
  */
26
41
  export class FallbackTransport {
27
42
  /** Resolves once one of the dials is ready; rejects with the WebSocket dial's failure, or when closed first. */
@@ -32,14 +47,16 @@ export class FallbackTransport {
32
47
  incomingUnidirectionalStreams;
33
48
  /** The winner's incoming bidirectional streams. */
34
49
  incomingBidirectionalStreams;
35
- #current;
36
- #carrier;
50
+ /** The dials still in progress. */
51
+ #dials = new Set();
37
52
  #winner;
38
- #cancelled = false;
53
+ #carrier;
54
+ /** Ends the race without a winner; unset once it has ended. */
55
+ #cancel;
39
56
  #won;
40
57
  constructor(url, protocols, options = {}) {
41
- const timeoutMs = assertHandshakeTimeout(options.handshakeTimeoutMs);
42
- this.#won = this.#dial(url, protocols, timeoutMs, options.onFallback);
58
+ const delayMs = assertFallbackOptions(options);
59
+ this.#won = this.#race(url, protocols, delayMs, options.onFallback);
43
60
  this.#won.catch(() => { });
44
61
  this.ready = this.#won.then(() => undefined);
45
62
  this.closed = this.#won.then((winner) => winner.closed);
@@ -47,7 +64,7 @@ export class FallbackTransport {
47
64
  this.incomingUnidirectionalStreams = this.#incoming((winner) => winner.incomingUnidirectionalStreams);
48
65
  this.incomingBidirectionalStreams = this.#incoming((winner) => winner.incomingBidirectionalStreams);
49
66
  }
50
- /** The transport the session runs on: the one in progress before `ready`, the winner after. */
67
+ /** The transport the session runs on; undefined until `ready`. */
51
68
  get carrier() {
52
69
  return this.#carrier;
53
70
  }
@@ -61,77 +78,105 @@ export class FallbackTransport {
61
78
  async createBidirectionalStream() {
62
79
  return (await this.#won).createBidirectionalStream();
63
80
  }
64
- /** Close the winner (TA-10); before `ready`, cancel whichever dial is in progress (TA-11). */
81
+ /** Close the winner (TA-10); before `ready`, cancel every dial in progress (TA-11). */
65
82
  close(info = {}) {
66
- if (!this.#winner)
67
- this.#cancelled = true;
68
- try {
69
- this.#current?.close(info);
70
- }
71
- catch {
72
- // A failed handshake may leave a transport that already refuses close().
73
- }
83
+ if (this.#winner)
84
+ closeQuietly(this.#winner, info);
85
+ else
86
+ this.#cancel?.(info);
74
87
  }
75
- async #dial(url, protocols, timeoutMs, onFallback) {
76
- const NativeWebTransport = usableWebTransport();
77
- let fallbackReason;
78
- let webTransport;
79
- if (NativeWebTransport) {
80
- try {
81
- webTransport = new NativeWebTransport(url, { protocols: [...protocols] });
82
- }
83
- catch (error) {
84
- // A runtime that refuses the dial outright (a policy, a URL it will not take) falls back too.
85
- fallbackReason = error;
86
- }
87
- }
88
- if (webTransport) {
89
- webTransport.closed.catch(() => { });
90
- this.#current = webTransport;
91
- this.#carrier = 'webtransport';
88
+ #race(url, protocols, delayMs, onFallback) {
89
+ return new Promise((resolve, reject) => {
92
90
  let timer;
93
- const timeout = new Promise((_, reject) => {
94
- timer = setTimeout(() => reject(new HandshakeTimeout(`the WebTransport handshake took longer than ${timeoutMs} ms`)), timeoutMs);
95
- });
96
- try {
97
- await Promise.race([webTransport.ready, timeout]);
98
- this.#cancelIfClosed();
99
- this.#winner = webTransport;
100
- return this.#winner;
101
- }
102
- catch (error) {
103
- this.#cancelIfClosed();
104
- fallbackReason = error;
105
- try {
106
- webTransport.close();
91
+ let webTransportPending = false;
92
+ let webTransportFailure;
93
+ let webSocketStarted = false;
94
+ let webSocketFailure;
95
+ const end = (info) => {
96
+ this.#cancel = undefined;
97
+ clearTimeout(timer);
98
+ for (const dial of this.#dials)
99
+ closeQuietly(dial, info);
100
+ this.#dials.clear();
101
+ };
102
+ this.#cancel = (info) => {
103
+ end(info);
104
+ reject(new WebSocketSessionError('the dial was cancelled'));
105
+ };
106
+ const win = (winner, carrier) => {
107
+ // A dial ready after the race ended lost it, or was cancelled.
108
+ if (!this.#cancel)
109
+ return closeQuietly(winner);
110
+ this.#dials.delete(winner);
111
+ end();
112
+ this.#winner = winner;
113
+ this.#carrier = carrier;
114
+ // Settled before the callback, so a close() from it closes the winner rather than cancelling a dial.
115
+ resolve(winner);
116
+ if (carrier === 'websocket') {
117
+ const reason = webTransportPending
118
+ ? new WebTransportOutpaced('the WebSocket was ready before the WebTransport handshake completed')
119
+ : webTransportFailure;
120
+ try {
121
+ onFallback?.(reason);
122
+ }
123
+ catch { }
107
124
  }
108
- catch { }
109
- }
110
- finally {
125
+ };
126
+ // Neither dial can still win: the connection fails with the WebSocket dial's failure.
127
+ const failIfLost = () => {
128
+ if (!this.#cancel || webTransportPending || !webSocketFailure)
129
+ return;
130
+ end();
131
+ reject(webSocketFailure.error);
132
+ };
133
+ const dialWebSocket = () => {
134
+ if (!this.#cancel || webSocketStarted)
135
+ return;
136
+ webSocketStarted = true;
111
137
  clearTimeout(timer);
138
+ let webSocket;
139
+ try {
140
+ webSocket = new WebSocketTransport(toWebSocketUrl(url), protocols);
141
+ }
142
+ catch (error) {
143
+ webSocketFailure = { error };
144
+ return failIfLost();
145
+ }
146
+ this.#dials.add(webSocket);
147
+ webSocket.ready.then(() => win(webSocket, 'websocket'), (error) => {
148
+ this.#dials.delete(webSocket);
149
+ webSocketFailure = { error };
150
+ failIfLost();
151
+ });
152
+ };
153
+ const NativeWebTransport = usableWebTransport();
154
+ let webTransport;
155
+ if (NativeWebTransport) {
156
+ try {
157
+ webTransport = new NativeWebTransport(url, { protocols: [...protocols] });
158
+ }
159
+ catch (error) {
160
+ // A runtime that refuses the dial outright (a policy, a URL it will not take) falls back too.
161
+ webTransportFailure = error;
162
+ }
112
163
  }
113
- }
114
- try {
115
- onFallback?.(fallbackReason);
116
- }
117
- catch { }
118
- const webSocket = new WebSocketTransport(toWebSocketUrl(url), protocols);
119
- this.#current = webSocket;
120
- this.#carrier = 'websocket';
121
- await webSocket.ready;
122
- this.#cancelIfClosed();
123
- this.#winner = webSocket;
124
- return webSocket;
125
- }
126
- /** Throws once close() came while a dial was in progress (TA-11). */
127
- #cancelIfClosed() {
128
- if (!this.#cancelled)
129
- return;
130
- try {
131
- this.#current?.close();
132
- }
133
- catch { }
134
- throw new WebSocketSessionError('the dial was cancelled');
164
+ if (!webTransport)
165
+ return dialWebSocket();
166
+ const dial = webTransport;
167
+ dial.closed.catch(() => { });
168
+ this.#dials.add(dial);
169
+ webTransportPending = true;
170
+ timer = setTimeout(dialWebSocket, delayMs);
171
+ dial.ready.then(() => win(dial, 'webtransport'), (error) => {
172
+ webTransportPending = false;
173
+ webTransportFailure = error;
174
+ if (this.#dials.delete(dial))
175
+ closeQuietly(dial);
176
+ dialWebSocket();
177
+ failIfLost();
178
+ });
179
+ });
135
180
  }
136
181
  /** The winner's incoming streams, one at a time; the readable ends with the winner's (TA-12). */
137
182
  #incoming(select) {
@@ -1 +1 @@
1
- {"version":3,"file":"fallback.js","sourceRoot":"","sources":["../src/fallback.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAwBpD,iGAAiG;AACjG,SAAS,kBAAkB;IACzB,IAAI,OAAO,YAAY,KAAK,WAAW;QAAE,OAAO,SAAS,CAAC;IAC1D,OAAO,UAAU,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC;AAED,4HAA4H;AAC5H,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,OAAO,KAAK,KAAK,QA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S,GAAG,EAAE,MAAM,EAAE,CAAC;YAC9B,CAAC;SACF,EACD,EAAE,aAAa,EAAE,CAAC,EAAE,CACrB,CAAC;IACJ,CAAC;CACF;AAED,iGAAiG;AACjG,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,QAAQ,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxB,KAAK,QAAQ,CAAC;QACd,KAAK,MAAM;YACT,OAAO,OAAO,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACpD,KAAK,OAAO,CAAC;QACb,KAAK,KAAK;YACR,OAAO,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD;YACE,MAAM,IAAI,SAAS,CAAC,kDAAkD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * (`spec/transport-adapter.md`), with the deviations the contract records for it.
6
6
  *
7
7
  * - {@link createWebSocketTransport}: always WebSocket.
8
- * - {@link withWebSocketFallback}: WebTransport first, WebSocket when its handshake fails or times out.
8
+ * - {@link withWebSocketFallback}: WebTransport first, racing a WebSocket once it has had a 250 ms head start.
9
9
  *
10
10
  * Pass either factory as the SDK's `createTransport`.
11
11
  *
@@ -57,18 +57,19 @@ export interface FallbackConnection {
57
57
  /** Resolves once one of the dials is ready and its peer selected a protocol. */
58
58
  ready: Promise<void>;
59
59
  /**
60
- * `'webtransport'` while the WebTransport dial is in progress or once it won, `'websocket'` once the dial fell back.
60
+ * `'webtransport'` while the dials are in progress or once WebTransport won, `'websocket'` once the WebSocket won.
61
61
  * Both carry the path and token in the URL, so the SDK's SETUP is the same either way.
62
62
  */
63
63
  readonly framing: FallbackCarrier;
64
64
  }
65
- /** Dials WebTransport, then QMux over WebSocket when that fails; see {@link withWebSocketFallback}. */
65
+ /** Dials WebTransport, then races QMux over WebSocket against it; see {@link withWebSocketFallback}. */
66
66
  export type FallbackTransportFactory = (url: string, protocols: string[]) => FallbackConnection;
67
67
  /**
68
- * A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first, and falls
69
- * back to QMux over WebSocket when that handshake fails or takes longer than `handshakeTimeoutMs` (default 4 s). Where
70
- * the runtime has no usable `WebTransport` (Safari before WebTransport, Node), it dials WebSocket at once. The dials
71
- * run one after the other, never both at once, and each connection decides afresh.
68
+ * A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first and, unless
69
+ * that handshake completes within `webSocketDelayMs` (default 250 ms, as Happy Eyeballs, RFC 8305), dials QMux over
70
+ * WebSocket alongside it. The first ready carries the session and the other dial is closed; a WebTransport handshake
71
+ * that fails sooner starts the WebSocket at once. Where the runtime has no usable `WebTransport` (Safari before
72
+ * WebTransport, Node), it dials WebSocket at once. Each connection decides afresh.
72
73
  *
73
74
  * ```ts
74
75
  * import { connectRelayPublisher } from '@caprid/relay';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAEL,KAAK,eAAe,EACpB,iBAAiB,EAEjB,KAAK,wBAAwB,EAC9B,MAAM,eAAe,CAAC;AAGvB,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAElG,iHAAiH;AACjH,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,kGAAkG;IAClG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CA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Ae,CAAC;AAElG,iHAAiH;AACjH,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,kGAAkG;IAClG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,mHAAmH;AACnH,MAAM,WAAW,mBAAmB;IAClC,8CAA8C;IAC9C,SAAS,EAAE,sBAAsB,CAAC;IAClC,qFAAqF;IACrF,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,kHAAkH;IAClH,OAAO,EAAE,WAAW,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,mBAAmB,CAAC;AAElG;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,IAAI,yBAAyB,CAKpE;AAED,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,kEAAkE;IAClE,SAAS,EAAE,iBAAiB,CAAC;IAC7B,gFAAgF;IAChF,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;CACnC;AAED,wGAAwG;AACxG,MAAM,MAAM,wBAAwB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,kBAAkB,CAAC;AAEhG;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,wBAA6B,GAAG,wBAAwB,CAYtG"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { assertHandshakeTimeout, FallbackTransport, toWebSocketUrl, } from './fallback.js';
1
+ import { assertFallbackOptions, FallbackTransport, toWebSocketUrl, } from './fallback.js';
2
2
  import { WebSocketTransport } from './transport.js';
3
3
  export { WebSocketSessionError } from './errors.js';
4
4
  /**
@@ -22,10 +22,11 @@ export function createWebSocketTransport() {
22
22
  };
23
23
  }
24
24
  /**
25
- * A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first, and falls
26
- * back to QMux over WebSocket when that handshake fails or takes longer than `handshakeTimeoutMs` (default 4 s). Where
27
- * the runtime has no usable `WebTransport` (Safari before WebTransport, Node), it dials WebSocket at once. The dials
28
- * run one after the other, never both at once, and each connection decides afresh.
25
+ * A transport factory for the SDK's `createTransport` option that dials the runtime's `WebTransport` first and, unless
26
+ * that handshake completes within `webSocketDelayMs` (default 250 ms, as Happy Eyeballs, RFC 8305), dials QMux over
27
+ * WebSocket alongside it. The first ready carries the session and the other dial is closed; a WebTransport handshake
28
+ * that fails sooner starts the WebSocket at once. Where the runtime has no usable `WebTransport` (Safari before
29
+ * WebTransport, Node), it dials WebSocket at once. Each connection decides afresh.
29
30
  *
30
31
  * ```ts
31
32
  * import { connectRelayPublisher } from '@caprid/relay';
@@ -35,7 +36,7 @@ export function createWebSocketTransport() {
35
36
  * ```
36
37
  */
37
38
  export function withWebSocketFallback(options = {}) {
38
- assertHandshakeTimeout(options.handshakeTimeoutMs);
39
+ assertFallbackOptions(options);
39
40
  return (url, protocols) => {
40
41
  const transport = new FallbackTransport(url, protocols, options);
41
42
  return {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,sBAAsB,EAEtB,iBAAiB,EACjB,cAAc,GAEf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAyBpD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;QACxB,MAAM,SAAS,GAAG,IAAI,kBAAkB,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;QACzE,OAAO,EAAE,SAAS,EAAE,KAAK,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AAE,SAAS,EAAE,EAAE;QACxB,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACjE,OAAO;YACL,SAAS;YACT,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,IAAI,OAAO;gBACT,OAAO,SAAS,CAAC,OAAO,IAAI,cAAc,CAAC;YAC7C,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caprid/relay-websocket",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "QMux-over-WebSocket transport adapter for the Relay SDK, for networks and browsers without WebTransport",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@moq/qmux": "0.3.3",
25
- "@caprid/moq-core": "0.1.1"
25
+ "@caprid/moq-core": "0.3.0"
26
26
  },
27
27
  "engines": {
28
28
  "node": ">=24"