@webtransport-bun/webtransport 0.2.3 → 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 +48 -4
- package/dist/index.d.ts +49 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +238 -80
- package/dist/streams.d.ts +3 -0
- package/dist/streams.d.ts.map +1 -1
- package/dist/streams.js +116 -22
- package/package.json +8 -6
- package/prebuilds/SHA256SUMS +4 -3
- package/prebuilds/webtransport-native.darwin-arm64.node +0 -0
- package/prebuilds/webtransport-native.darwin-x64.node +0 -0
- package/prebuilds/webtransport-native.linux-x64-gnu.node +0 -0
- package/prebuilds/webtransport-native.win32-x64-msvc.node +0 -0
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ yarn add @webtransport-bun/webtransport
|
|
|
14
14
|
## Requirements
|
|
15
15
|
|
|
16
16
|
- **Runtime**: Bun >= 1.3.9, Node (Node-API compatible runtime), Deno (npm + Node-API addon support)
|
|
17
|
-
- **Platforms**: macOS (arm64, x64), Linux (x64)
|
|
17
|
+
- **Platforms**: macOS (arm64, x64), Linux (x64), Windows (x64)
|
|
18
18
|
|
|
19
19
|
## Quick Start
|
|
20
20
|
|
|
@@ -31,6 +31,34 @@ const server = createServer({
|
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
+
// Hot-swap TLS leaf cert/key material without dropping existing sessions.
|
|
35
|
+
// New handshakes immediately use the new certificate.
|
|
36
|
+
// Transport config and bind-address changes still require rebuilding the server.
|
|
37
|
+
await server.updateCert({ certPem: "...next cert...", keyPem: "...next key..." });
|
|
38
|
+
|
|
39
|
+
// Or atomically replace the full TLS configuration, including hostname-specific SNI certs.
|
|
40
|
+
await server.updateTls({
|
|
41
|
+
certPem: "...default cert...",
|
|
42
|
+
keyPem: "...default key...",
|
|
43
|
+
sni: [
|
|
44
|
+
{
|
|
45
|
+
serverName: "api.example.test",
|
|
46
|
+
certPem: "...api cert...",
|
|
47
|
+
keyPem: "...api key...",
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
unknownSniPolicy: "reject",
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Or manage the hostname map incrementally.
|
|
54
|
+
await server.upsertSniCert({
|
|
55
|
+
serverName: "admin.example.test",
|
|
56
|
+
certPem: "...admin cert...",
|
|
57
|
+
keyPem: "...admin key...",
|
|
58
|
+
});
|
|
59
|
+
await server.setUnknownSniPolicy("default");
|
|
60
|
+
console.log(server.tlsSnapshot());
|
|
61
|
+
|
|
34
62
|
const session = await connect("https://127.0.0.1:4433", {
|
|
35
63
|
tls: { insecureSkipVerify: true }, // dev only
|
|
36
64
|
});
|
|
@@ -40,11 +68,27 @@ session.close();
|
|
|
40
68
|
|
|
41
69
|
## Troubleshooting
|
|
42
70
|
|
|
71
|
+
## TLS hot-swap and SNI
|
|
72
|
+
|
|
73
|
+
- `updateCert()` changes only the default server certificate/key.
|
|
74
|
+
- `updateTls()` atomically replaces the default certificate/key, full SNI certificate map, and unknown-SNI policy.
|
|
75
|
+
- `replaceSniCerts()` swaps the full SNI certificate map while preserving the default certificate/key and current unknown-SNI policy.
|
|
76
|
+
- `upsertSniCert()` and `removeSniCert()` manage individual hostname mappings in place.
|
|
77
|
+
- `setUnknownSniPolicy()` changes only unknown-SNI handling in place.
|
|
78
|
+
- `tlsSnapshot()` returns sorted active SNI hostnames in canonical ASCII form plus the current unknown-SNI policy.
|
|
79
|
+
- Wildcards are supported only as left-most single-label entries such as `*.example.com`; exact hostnames win over wildcards.
|
|
80
|
+
- SNI hostnames are IDNA-normalized to canonical ASCII, so Unicode names are stored and matched by their punycode form.
|
|
81
|
+
- Review configured Unicode hostnames for homograph/confusable risk; IDNA normalization makes names protocol-correct, not human-safe.
|
|
82
|
+
- When `tls.sni` is configured, `unknownSniPolicy` defaults to `"reject"` for unknown hostnames.
|
|
83
|
+
- Clients that do not send SNI still receive the default certificate.
|
|
84
|
+
- `tls.sni` and `unknownSniPolicy` require a non-empty default server certificate/key.
|
|
85
|
+
- Bind-address or transport-config changes still require rebuilding/restarting the server.
|
|
86
|
+
|
|
43
87
|
### "Native addon not loaded"
|
|
44
88
|
|
|
45
|
-
|
|
89
|
+
Published npm packages and GitHub release artifacts include prebuilt binaries for darwin-arm64, darwin-x64, linux-x64, and win32-x64-msvc. A source checkout may only have whatever prebuilds were generated locally. If you see this error:
|
|
46
90
|
|
|
47
|
-
- Ensure you are on a supported platform (macOS
|
|
91
|
+
- Ensure you are on a supported platform (macOS/Linux/Windows on supported arch).
|
|
48
92
|
- Reinstall dependencies and rebuild native artifacts (`npm i` / `pnpm i` / `yarn` / `bun install`).
|
|
49
93
|
- For development from source, run `bun run build:native` from the repo root.
|
|
50
94
|
|
|
@@ -53,7 +97,7 @@ Prebuilt binaries are included for darwin-arm64, darwin-x64, and linux-x64. If y
|
|
|
53
97
|
This package supports Bun, Node, and Deno on supported OS/arch targets. If import fails:
|
|
54
98
|
|
|
55
99
|
- Confirm your runtime supports Node-API addon loading.
|
|
56
|
-
- Confirm your platform matches published prebuilds (macOS arm64/x64, Linux x64).
|
|
100
|
+
- Confirm your platform matches published prebuilds (macOS arm64/x64, Linux x64, Windows x64).
|
|
57
101
|
- If needed, build native locally from source (`bun run build:native` in this repo).
|
|
58
102
|
|
|
59
103
|
## Docs
|
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,20 @@ export { E_TLS, E_HANDSHAKE_TIMEOUT, E_SESSION_CLOSED, E_SESSION_IDLE_TIMEOUT, E
|
|
|
50
50
|
export type { ErrorCode, WebTransportErrorOptions, WebTransportErrorSource, } from "./errors.js";
|
|
51
51
|
/** Web IDL BufferSource (ArrayBuffer | ArrayBufferView) for spec alignment */
|
|
52
52
|
type BufferSource = ArrayBuffer | ArrayBufferView;
|
|
53
|
+
type StreamOpenOptions = {
|
|
54
|
+
waitUntilAvailable?: boolean;
|
|
55
|
+
};
|
|
53
56
|
/** TLS configuration for server (cert/key) or client (CA, SNI). */
|
|
57
|
+
export type ServerTlsSniEntry = {
|
|
58
|
+
serverName: string;
|
|
59
|
+
certPem: string | Uint8Array;
|
|
60
|
+
keyPem: string | Uint8Array;
|
|
61
|
+
};
|
|
62
|
+
export type UnknownSniPolicy = "reject" | "default";
|
|
63
|
+
export type ServerTlsSnapshot = {
|
|
64
|
+
sniServerNames: string[];
|
|
65
|
+
unknownSniPolicy: UnknownSniPolicy;
|
|
66
|
+
};
|
|
54
67
|
export type TlsOptions = {
|
|
55
68
|
/** PEM-encoded certificate (server) or CA (client). */
|
|
56
69
|
certPem: string | Uint8Array;
|
|
@@ -60,6 +73,12 @@ export type TlsOptions = {
|
|
|
60
73
|
caPem?: string | Uint8Array;
|
|
61
74
|
/** SNI for client mode; for server, used in logs/metrics. */
|
|
62
75
|
serverName?: string;
|
|
76
|
+
/** Optional additional SNI certificates for server mode. */
|
|
77
|
+
sni?: ServerTlsSniEntry[];
|
|
78
|
+
/** Unknown SNI handling for server mode. Default "reject". No-SNI still uses default cert. */
|
|
79
|
+
unknownSniPolicy?: UnknownSniPolicy;
|
|
80
|
+
/** When true, allow empty cert/key fallback in production (dev only). */
|
|
81
|
+
allowSelfSigned?: boolean;
|
|
63
82
|
};
|
|
64
83
|
export type RateLimitOptions = {
|
|
65
84
|
handshakesPerSec: number;
|
|
@@ -130,6 +149,23 @@ export interface WebTransportServer {
|
|
|
130
149
|
host: string;
|
|
131
150
|
port: number;
|
|
132
151
|
};
|
|
152
|
+
/** Rotate only the default server TLS certificate/key at runtime. Existing sessions stay alive. */
|
|
153
|
+
updateCert(tls: {
|
|
154
|
+
certPem: string | Uint8Array;
|
|
155
|
+
keyPem: string | Uint8Array;
|
|
156
|
+
}): Promise<void>;
|
|
157
|
+
/** Atomically replace the full server TLS configuration, including SNI certs and unknown-SNI policy. */
|
|
158
|
+
updateTls(tls: TlsOptions): Promise<void>;
|
|
159
|
+
/** Replace only the full SNI cert map, preserving the default cert/key and unknown-SNI policy. */
|
|
160
|
+
replaceSniCerts(sni: ServerTlsSniEntry[]): Promise<void>;
|
|
161
|
+
/** Add or replace one hostname-specific SNI certificate. */
|
|
162
|
+
upsertSniCert(entry: ServerTlsSniEntry): Promise<void>;
|
|
163
|
+
/** Remove one hostname-specific SNI certificate. */
|
|
164
|
+
removeSniCert(serverName: string): Promise<void>;
|
|
165
|
+
/** Update only the unknown-SNI policy. */
|
|
166
|
+
setUnknownSniPolicy(policy: UnknownSniPolicy): Promise<void>;
|
|
167
|
+
/** Introspect the active server TLS SNI state without exposing key material. */
|
|
168
|
+
tlsSnapshot(): ServerTlsSnapshot;
|
|
133
169
|
close(): Promise<void>;
|
|
134
170
|
metricsSnapshot(): MetricsSnapshot;
|
|
135
171
|
}
|
|
@@ -236,15 +272,15 @@ interface CommonSession {
|
|
|
236
272
|
export interface ServerSession extends CommonSession {
|
|
237
273
|
readonly incomingBidirectionalStreams: ReadableStream<WebTransportBidirectionalStream>;
|
|
238
274
|
readonly incomingUnidirectionalStreams: ReadableStream<WebTransportReceiveStream>;
|
|
239
|
-
createBidirectionalStream(): Promise<Duplex>;
|
|
240
|
-
createUnidirectionalStream(): Promise<Writable>;
|
|
275
|
+
createBidirectionalStream(options?: StreamOpenOptions): Promise<Duplex>;
|
|
276
|
+
createUnidirectionalStream(options?: StreamOpenOptions): Promise<Writable>;
|
|
241
277
|
metricsSnapshot(): SessionMetricsSnapshot;
|
|
242
278
|
}
|
|
243
279
|
/** Node client API session surface returned by connect(). */
|
|
244
280
|
export interface ClientSession extends CommonSession {
|
|
245
|
-
createBidirectionalStream(): Promise<Duplex>;
|
|
281
|
+
createBidirectionalStream(options?: StreamOpenOptions): Promise<Duplex>;
|
|
246
282
|
incomingBidirectionalStreams(): AsyncIterable<Duplex>;
|
|
247
|
-
createUnidirectionalStream(): Promise<Writable>;
|
|
283
|
+
createUnidirectionalStream(options?: StreamOpenOptions): Promise<Writable>;
|
|
248
284
|
incomingUnidirectionalStreams(): AsyncIterable<Readable>;
|
|
249
285
|
metricsSnapshot(): SessionMetricsSnapshot;
|
|
250
286
|
}
|
|
@@ -270,6 +306,9 @@ export type MetricsSnapshot = {
|
|
|
270
306
|
backpressureTimeoutCount: number;
|
|
271
307
|
rateLimitedCount: number;
|
|
272
308
|
limitExceededCount: number;
|
|
309
|
+
sniCertSelections: number;
|
|
310
|
+
defaultCertSelections: number;
|
|
311
|
+
unknownSniRejectedCount: number;
|
|
273
312
|
/** Handshake latency (accept start to completion). P99 target <300ms. */
|
|
274
313
|
handshakeLatency?: HistogramSnapshot | null;
|
|
275
314
|
/** Datagram send enqueue latency. P99 target <10ms. */
|
|
@@ -334,7 +373,7 @@ declare function buildNativeAddonLoadErrorMessage(failures: NativeLoadFailure[],
|
|
|
334
373
|
* Create an in-process WebTransport server.
|
|
335
374
|
*
|
|
336
375
|
* @param opts - Server configuration. Requires `port`, `tls` (certPem, keyPem), and `onSession` callback.
|
|
337
|
-
* @returns WebTransportServer with
|
|
376
|
+
* @returns WebTransportServer with address, live TLS management methods, `close()`, and `metricsSnapshot()`.
|
|
338
377
|
* @throws Error if native addon is not loaded.
|
|
339
378
|
*
|
|
340
379
|
* @example
|
|
@@ -353,7 +392,7 @@ declare function buildNativeAddonLoadErrorMessage(failures: NativeLoadFailure[],
|
|
|
353
392
|
* ```
|
|
354
393
|
*/
|
|
355
394
|
export declare function createServer(opts: ServerOptions): WebTransportServer;
|
|
356
|
-
declare function connectWithNative(native: any, url: string, optsJson: string, handshakeTimeout: number, strictW3CErrors?: boolean, setTimer?: (cb: () => void, ms: number) => any, clearTimer?: (handle: any) => void): Promise<ClientSession>;
|
|
395
|
+
declare function connectWithNative(native: any, url: string, optsJson: string, handshakeTimeout: number, strictW3CErrors?: boolean, streamOpenWaitTimeoutMs?: number, setTimer?: (cb: () => void, ms: number) => any, clearTimer?: (handle: any) => void): Promise<ClientSession>;
|
|
357
396
|
/**
|
|
358
397
|
* Connect to a WebTransport server (Node API).
|
|
359
398
|
*
|
|
@@ -440,6 +479,7 @@ export declare class WebTransport {
|
|
|
440
479
|
createBidirectionalStream(options?: {
|
|
441
480
|
sendOrder?: number;
|
|
442
481
|
sendGroup?: WebTransportSendGroup | null;
|
|
482
|
+
waitUntilAvailable?: boolean;
|
|
443
483
|
}): Promise<{
|
|
444
484
|
readable: ReadableStream<Uint8Array>;
|
|
445
485
|
writable: WritableStream<Uint8Array>;
|
|
@@ -451,6 +491,7 @@ export declare class WebTransport {
|
|
|
451
491
|
createUnidirectionalStream(options?: {
|
|
452
492
|
sendOrder?: number;
|
|
453
493
|
sendGroup?: WebTransportSendGroup | null;
|
|
494
|
+
waitUntilAvailable?: boolean;
|
|
454
495
|
}): Promise<WritableStream<Uint8Array>>;
|
|
455
496
|
/**
|
|
456
497
|
* Get connection stats (W3C WebTransportConnectionStats).
|
|
@@ -464,9 +505,11 @@ export declare class WebTransport {
|
|
|
464
505
|
_getSession(): Promise<ClientSession>;
|
|
465
506
|
/** Internal: state for createWritable guard (not part of spec) */
|
|
466
507
|
_getState(): WebTransportState;
|
|
508
|
+
_isStrictW3CErrors(): boolean;
|
|
467
509
|
_resolveSendPolicy(options?: {
|
|
468
510
|
sendOrder?: number;
|
|
469
511
|
sendGroup?: WebTransportSendGroup | null;
|
|
512
|
+
waitUntilAvailable?: boolean;
|
|
470
513
|
}): SendPolicy;
|
|
471
514
|
_recordSendGroupBytes(groupId: number, bytes: number): void;
|
|
472
515
|
_getSendGroupStats(groupId: number): Promise<{
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACzD,YAAY,EAAE,UAA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_TLS, E_HANDSHAKE_TIMEOUT, E_SESSION_CLOSED, E_SESSION_IDLE_TIMEOUT, E_STREAM_RESET, E_STOP_SENDING, E_QUEUE_FULL, E_BACKPRESSURE_TIMEOUT, E_LIMIT_EXCEEDED, E_RATE_LIMITED, E_INTERNAL, WebTransportError, } from "./errors.js";
|
|
16
|
-
import { E_INTERNAL, E_HANDSHAKE_TIMEOUT, E_SESSION_CLOSED, E_SESSION_IDLE_TIMEOUT, WebTransportError, } from "./errors.js";
|
|
16
|
+
import { E_TLS, E_INTERNAL, E_HANDSHAKE_TIMEOUT, E_LIMIT_EXCEEDED, E_QUEUE_FULL, E_BACKPRESSURE_TIMEOUT, E_SESSION_CLOSED, E_SESSION_IDLE_TIMEOUT, E_STREAM_RESET, E_STOP_SENDING, E_RATE_LIMITED, WebTransportError, } from "./errors.js";
|
|
17
17
|
const E_CODE_RE = /E_[A-Z_]+/g;
|
|
18
|
+
const SUPPRESS_LOG_CALLBACK_WARN = process.env.WEBTRANSPORT_SUPPRESS_LOG_CALLBACK_WARN === "1";
|
|
19
|
+
const SUPPRESS_READY_REJECTION_WARN = process.env.WEBTRANSPORT_SUPPRESS_READY_REJECTION_WARN === "1";
|
|
18
20
|
/**
|
|
19
21
|
* Maps known validation/connect failures to browser-style DOMException names.
|
|
20
22
|
* Returns undefined for unknown cases; E_* code is always preserved.
|
|
@@ -27,29 +29,51 @@ function normalizeToBrowserName(code, message) {
|
|
|
27
29
|
if (message.includes("serverCertificateHashes must be an array")) {
|
|
28
30
|
return "TypeError";
|
|
29
31
|
}
|
|
32
|
+
if (message.includes("serverCertificateHashes entry value must be") ||
|
|
33
|
+
message.includes("invalid base64 in serverCertificateHashes")) {
|
|
34
|
+
return "TypeError";
|
|
35
|
+
}
|
|
30
36
|
if (message.includes("allowPooling must be a boolean") ||
|
|
31
37
|
message.includes("requireUnreliable must be a boolean")) {
|
|
32
38
|
return "TypeError";
|
|
33
39
|
}
|
|
34
40
|
if (message.includes("congestionControl must be") ||
|
|
35
|
-
message.includes("datagramsReadableType must be")
|
|
41
|
+
message.includes("datagramsReadableType must be") ||
|
|
42
|
+
message.includes("waitUntilAvailable must be a boolean")) {
|
|
36
43
|
return "TypeError";
|
|
37
44
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
switch (code) {
|
|
46
|
+
case E_TLS:
|
|
47
|
+
return "NetworkError";
|
|
48
|
+
case E_HANDSHAKE_TIMEOUT:
|
|
49
|
+
case E_BACKPRESSURE_TIMEOUT:
|
|
50
|
+
return "TimeoutError";
|
|
51
|
+
case E_SESSION_CLOSED:
|
|
52
|
+
case E_SESSION_IDLE_TIMEOUT:
|
|
53
|
+
return "InvalidStateError";
|
|
54
|
+
case E_STREAM_RESET:
|
|
55
|
+
case E_STOP_SENDING:
|
|
56
|
+
return "AbortError";
|
|
57
|
+
case E_LIMIT_EXCEEDED:
|
|
58
|
+
case E_QUEUE_FULL:
|
|
59
|
+
case E_RATE_LIMITED:
|
|
60
|
+
return "QuotaExceededError";
|
|
61
|
+
case E_INTERNAL:
|
|
62
|
+
return "OperationError";
|
|
44
63
|
}
|
|
45
64
|
return undefined;
|
|
46
65
|
}
|
|
66
|
+
function createMappedError(code, message, strictW3CErrors) {
|
|
67
|
+
const browserName = strictW3CErrors === true
|
|
68
|
+
? normalizeToBrowserName(code, message)
|
|
69
|
+
: undefined;
|
|
70
|
+
return new WebTransportError(code, message, browserName ? { browserName } : undefined);
|
|
71
|
+
}
|
|
47
72
|
function toWebTransportError(err, strictW3CErrors) {
|
|
48
73
|
const msg = err instanceof Error ? err.message : String(err);
|
|
49
74
|
const match = msg.match(E_CODE_RE);
|
|
50
75
|
const code = match ? match[0] : E_INTERNAL;
|
|
51
|
-
|
|
52
|
-
return new WebTransportError(code, msg, browserName ? { browserName } : undefined);
|
|
76
|
+
return createMappedError(code, msg, strictW3CErrors);
|
|
53
77
|
}
|
|
54
78
|
function isSessionCloseError(err) {
|
|
55
79
|
const mapped = toWebTransportError(err);
|
|
@@ -63,6 +87,55 @@ function isSessionCloseError(err) {
|
|
|
63
87
|
return (lower.includes("connection locally closed") ||
|
|
64
88
|
lower.includes("connection closed by peer"));
|
|
65
89
|
}
|
|
90
|
+
function shouldRetryStreamOpen(err) {
|
|
91
|
+
const mapped = toWebTransportError(err);
|
|
92
|
+
return (mapped.code === E_LIMIT_EXCEEDED ||
|
|
93
|
+
mapped.code === E_QUEUE_FULL ||
|
|
94
|
+
mapped.code === E_BACKPRESSURE_TIMEOUT);
|
|
95
|
+
}
|
|
96
|
+
function parseWaitUntilAvailable(options) {
|
|
97
|
+
const value = options?.waitUntilAvailable;
|
|
98
|
+
if (value === undefined)
|
|
99
|
+
return false;
|
|
100
|
+
if (typeof value !== "boolean") {
|
|
101
|
+
throw new TypeError("waitUntilAvailable must be a boolean");
|
|
102
|
+
}
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
async function openStreamWithWait(openFn, options, backpressureTimeoutMs, isClosed, waitForCapacity, strictW3CErrors) {
|
|
106
|
+
const waitUntilAvailable = parseWaitUntilAvailable(options);
|
|
107
|
+
if (!waitUntilAvailable) {
|
|
108
|
+
return openFn();
|
|
109
|
+
}
|
|
110
|
+
const timeoutMs = Math.max(1, backpressureTimeoutMs);
|
|
111
|
+
const deadline = Date.now() + timeoutMs;
|
|
112
|
+
let backoffMs = 2;
|
|
113
|
+
while (true) {
|
|
114
|
+
if (isClosed()) {
|
|
115
|
+
throw new WebTransportError(E_SESSION_CLOSED);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
return await openFn();
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
if (!shouldRetryStreamOpen(err)) {
|
|
122
|
+
throw toWebTransportError(err, strictW3CErrors);
|
|
123
|
+
}
|
|
124
|
+
if (Date.now() >= deadline) {
|
|
125
|
+
throw new WebTransportError(E_BACKPRESSURE_TIMEOUT, `E_BACKPRESSURE_TIMEOUT: waitUntilAvailable timed out after ${timeoutMs}ms`);
|
|
126
|
+
}
|
|
127
|
+
const remaining = Math.max(0, deadline - Date.now());
|
|
128
|
+
if (waitForCapacity) {
|
|
129
|
+
await waitForCapacity(Math.max(1, remaining));
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const sleepMs = Math.max(1, Math.min(backoffMs, remaining));
|
|
133
|
+
await Bun.sleep(sleepMs);
|
|
134
|
+
backoffMs = Math.min(backoffMs * 2, 64);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
66
139
|
/** Default limit values from AGENTS.md */
|
|
67
140
|
export const DEFAULT_LIMITS = {
|
|
68
141
|
maxSessions: 2000,
|
|
@@ -188,6 +261,15 @@ export function metricsToPrometheus(m, labels) {
|
|
|
188
261
|
`# HELP ${p}limit_exceeded_total Sessions rejected (limits)`,
|
|
189
262
|
`# TYPE ${p}limit_exceeded_total counter`,
|
|
190
263
|
`${p}limit_exceeded_total${metricLabels} ${m.limitExceededCount}`,
|
|
264
|
+
`# HELP ${p}tls_sni_cert_selections_total Handshakes served by hostname-specific SNI certs`,
|
|
265
|
+
`# TYPE ${p}tls_sni_cert_selections_total counter`,
|
|
266
|
+
`${p}tls_sni_cert_selections_total${metricLabels} ${m.sniCertSelections}`,
|
|
267
|
+
`# HELP ${p}tls_default_cert_selections_total Handshakes served by the default certificate`,
|
|
268
|
+
`# TYPE ${p}tls_default_cert_selections_total counter`,
|
|
269
|
+
`${p}tls_default_cert_selections_total${metricLabels} ${m.defaultCertSelections}`,
|
|
270
|
+
`# HELP ${p}tls_unknown_sni_rejected_total Handshakes rejected because SNI did not match a configured hostname`,
|
|
271
|
+
`# TYPE ${p}tls_unknown_sni_rejected_total counter`,
|
|
272
|
+
`${p}tls_unknown_sni_rejected_total${metricLabels} ${m.unknownSniRejectedCount}`,
|
|
191
273
|
];
|
|
192
274
|
function emitHistogram(name, h) {
|
|
193
275
|
if (!h)
|
|
@@ -232,6 +314,7 @@ const PLATFORM = process.platform;
|
|
|
232
314
|
const ARCH = process.arch;
|
|
233
315
|
const binaryCandidates = [
|
|
234
316
|
`webtransport-native.${PLATFORM}-${ARCH}.node`,
|
|
317
|
+
`webtransport-native.${PLATFORM}-${ARCH}-msvc.node`,
|
|
235
318
|
`webtransport-native.${PLATFORM}-${ARCH}-gnu.node`,
|
|
236
319
|
`webtransport-native.${PLATFORM}-${ARCH}-musl.node`,
|
|
237
320
|
];
|
|
@@ -280,10 +363,12 @@ class NativeServerSession {
|
|
|
280
363
|
#closedPromise;
|
|
281
364
|
#closed = false;
|
|
282
365
|
#requestedCloseInfo = null;
|
|
366
|
+
#streamOpenWaitTimeoutMs;
|
|
283
367
|
#incomingBidiCache = null;
|
|
284
368
|
#incomingUniCache = null;
|
|
285
|
-
constructor(nativeHandle, closedPromise) {
|
|
369
|
+
constructor(nativeHandle, closedPromise, streamOpenWaitTimeoutMs) {
|
|
286
370
|
this.#nativeHandle = nativeHandle;
|
|
371
|
+
this.#streamOpenWaitTimeoutMs = streamOpenWaitTimeoutMs;
|
|
287
372
|
this.#closedPromise = closedPromise.then((info) => normalizeCloseInfo(info, this.#requestedCloseInfo ?? undefined));
|
|
288
373
|
this.#closedPromise.then(() => {
|
|
289
374
|
this.#closed = true;
|
|
@@ -338,11 +423,13 @@ class NativeServerSession {
|
|
|
338
423
|
}
|
|
339
424
|
}
|
|
340
425
|
}
|
|
341
|
-
async createBidirectionalStream() {
|
|
426
|
+
async createBidirectionalStream(options) {
|
|
342
427
|
if (this.#closed)
|
|
343
428
|
throw new WebTransportError(E_SESSION_CLOSED);
|
|
344
429
|
try {
|
|
345
|
-
const nativeStream = await this.#nativeHandle.createBidiStream()
|
|
430
|
+
const nativeStream = (await openStreamWithWait(() => this.#nativeHandle.createBidiStream(), options, this.#streamOpenWaitTimeoutMs, () => this.#closed, typeof this.#nativeHandle.waitBidiCapacity === "function"
|
|
431
|
+
? (remainingMs) => this.#nativeHandle.waitBidiCapacity(remainingMs)
|
|
432
|
+
: undefined));
|
|
346
433
|
return new BidiStream({
|
|
347
434
|
handleId: nativeStream?.id ?? 0,
|
|
348
435
|
nativeHandle: nativeStream,
|
|
@@ -358,11 +445,13 @@ class NativeServerSession {
|
|
|
358
445
|
}
|
|
359
446
|
return this.#incomingBidiCache;
|
|
360
447
|
}
|
|
361
|
-
async createUnidirectionalStream() {
|
|
448
|
+
async createUnidirectionalStream(options) {
|
|
362
449
|
if (this.#closed)
|
|
363
450
|
throw new WebTransportError(E_SESSION_CLOSED);
|
|
364
451
|
try {
|
|
365
|
-
const nativeStream = await this.#nativeHandle.createUniStream()
|
|
452
|
+
const nativeStream = (await openStreamWithWait(() => this.#nativeHandle.createUniStream(), options, this.#streamOpenWaitTimeoutMs, () => this.#closed, typeof this.#nativeHandle.waitUniCapacity === "function"
|
|
453
|
+
? (remainingMs) => this.#nativeHandle.waitUniCapacity(remainingMs)
|
|
454
|
+
: undefined));
|
|
366
455
|
return new SendStream({
|
|
367
456
|
handleId: nativeStream?.id ?? 0,
|
|
368
457
|
nativeHandle: nativeStream,
|
|
@@ -389,7 +478,7 @@ class NativeServerSession {
|
|
|
389
478
|
* Create an in-process WebTransport server.
|
|
390
479
|
*
|
|
391
480
|
* @param opts - Server configuration. Requires `port`, `tls` (certPem, keyPem), and `onSession` callback.
|
|
392
|
-
* @returns WebTransportServer with
|
|
481
|
+
* @returns WebTransportServer with address, live TLS management methods, `close()`, and `metricsSnapshot()`.
|
|
393
482
|
* @throws Error if native addon is not loaded.
|
|
394
483
|
*
|
|
395
484
|
* @example
|
|
@@ -409,18 +498,32 @@ class NativeServerSession {
|
|
|
409
498
|
*/
|
|
410
499
|
export function createServer(opts) {
|
|
411
500
|
const native = getNativeOrThrow();
|
|
412
|
-
const
|
|
413
|
-
?
|
|
414
|
-
:
|
|
415
|
-
|
|
416
|
-
? opts.tls.keyPem
|
|
417
|
-
: new TextDecoder().decode(opts.tls.keyPem);
|
|
418
|
-
const caPem = typeof opts.tls.caPem === "string"
|
|
419
|
-
? opts.tls.caPem
|
|
420
|
-
: opts.tls.caPem != null
|
|
421
|
-
? new TextDecoder().decode(opts.tls.caPem)
|
|
501
|
+
const decodePem = (value) => typeof value === "string"
|
|
502
|
+
? value
|
|
503
|
+
: value != null
|
|
504
|
+
? new TextDecoder().decode(value)
|
|
422
505
|
: "";
|
|
423
|
-
const
|
|
506
|
+
const certPem = decodePem(opts.tls.certPem);
|
|
507
|
+
const keyPem = decodePem(opts.tls.keyPem);
|
|
508
|
+
if (process.env.NODE_ENV === "production" &&
|
|
509
|
+
opts.tls.allowSelfSigned !== true &&
|
|
510
|
+
(certPem.trim().length === 0 || keyPem.trim().length === 0)) {
|
|
511
|
+
throw new WebTransportError(E_TLS, "E_TLS: empty certPem/keyPem is not allowed in production (set tls.allowSelfSigned=true to override)");
|
|
512
|
+
}
|
|
513
|
+
const caPem = decodePem(opts.tls.caPem);
|
|
514
|
+
const tlsConfigToJson = (tls) => JSON.stringify({
|
|
515
|
+
certPem: decodePem(tls.certPem),
|
|
516
|
+
keyPem: decodePem(tls.keyPem),
|
|
517
|
+
caPem: decodePem(tls.caPem),
|
|
518
|
+
unknownSniPolicy: tls.unknownSniPolicy,
|
|
519
|
+
sni: tls.sni?.map((entry) => ({
|
|
520
|
+
serverName: entry.serverName,
|
|
521
|
+
certPem: decodePem(entry.certPem),
|
|
522
|
+
keyPem: decodePem(entry.keyPem),
|
|
523
|
+
})) ?? [],
|
|
524
|
+
});
|
|
525
|
+
const mergedLimits = { ...DEFAULT_LIMITS, ...opts.limits };
|
|
526
|
+
const limitsJson = JSON.stringify(mergedLimits);
|
|
424
527
|
const rateLimitsJson = JSON.stringify({
|
|
425
528
|
...DEFAULT_RATE_LIMITS,
|
|
426
529
|
...opts.rateLimits,
|
|
@@ -435,8 +538,10 @@ export function createServer(opts) {
|
|
|
435
538
|
opts.log(event);
|
|
436
539
|
}
|
|
437
540
|
catch (err) {
|
|
438
|
-
|
|
439
|
-
|
|
541
|
+
if (!SUPPRESS_LOG_CALLBACK_WARN) {
|
|
542
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
543
|
+
console.warn(`[webtransport] log callback failed: ${msg}`);
|
|
544
|
+
}
|
|
440
545
|
}
|
|
441
546
|
};
|
|
442
547
|
const logCallback = (logEvents) => {
|
|
@@ -450,7 +555,7 @@ export function createServer(opts) {
|
|
|
450
555
|
});
|
|
451
556
|
}
|
|
452
557
|
};
|
|
453
|
-
const handle = new native.ServerHandle(opts.port, opts.host ?? "0.0.0.0", opts.debug === true,
|
|
558
|
+
const handle = new native.ServerHandle(opts.port, opts.host ?? "0.0.0.0", opts.debug === true, tlsConfigToJson(opts.tls), limitsJson, rateLimitsJson, (events) => {
|
|
454
559
|
for (const evt of events) {
|
|
455
560
|
if (evt.name === "session" &&
|
|
456
561
|
evt.id != null &&
|
|
@@ -462,7 +567,7 @@ export function createServer(opts) {
|
|
|
462
567
|
});
|
|
463
568
|
closedResolvers.set(evt.id, closedResolve);
|
|
464
569
|
const nativeSession = new native.SessionHandle(evt.id, evt.peerIp, evt.peerPort);
|
|
465
|
-
const session = new NativeServerSession(nativeSession, closedPromise);
|
|
570
|
+
const session = new NativeServerSession(nativeSession, closedPromise, mergedLimits.backpressureTimeoutMs);
|
|
466
571
|
activeOnSessionCallbacks++;
|
|
467
572
|
let maybePromise;
|
|
468
573
|
try {
|
|
@@ -514,6 +619,31 @@ export function createServer(opts) {
|
|
|
514
619
|
}
|
|
515
620
|
return {
|
|
516
621
|
address: { host: opts.host ?? "0.0.0.0", port: handle.port },
|
|
622
|
+
updateCert: async (tls) => {
|
|
623
|
+
const nextCertPem = decodePem(tls.certPem);
|
|
624
|
+
const nextKeyPem = decodePem(tls.keyPem);
|
|
625
|
+
await handle.updateCert(nextCertPem, nextKeyPem);
|
|
626
|
+
},
|
|
627
|
+
updateTls: async (tls) => {
|
|
628
|
+
await handle.updateTls(tlsConfigToJson(tls));
|
|
629
|
+
},
|
|
630
|
+
replaceSniCerts: async (sni) => {
|
|
631
|
+
await handle.replaceSniCerts(JSON.stringify(sni.map((entry) => ({
|
|
632
|
+
serverName: entry.serverName,
|
|
633
|
+
certPem: decodePem(entry.certPem),
|
|
634
|
+
keyPem: decodePem(entry.keyPem),
|
|
635
|
+
}))));
|
|
636
|
+
},
|
|
637
|
+
upsertSniCert: async (entry) => {
|
|
638
|
+
await handle.upsertSniCert(entry.serverName, decodePem(entry.certPem), decodePem(entry.keyPem));
|
|
639
|
+
},
|
|
640
|
+
removeSniCert: async (serverName) => {
|
|
641
|
+
await handle.removeSniCert(serverName);
|
|
642
|
+
},
|
|
643
|
+
setUnknownSniPolicy: async (policy) => {
|
|
644
|
+
await handle.setUnknownSniPolicy(policy);
|
|
645
|
+
},
|
|
646
|
+
tlsSnapshot: () => handle.tlsSnapshot(),
|
|
517
647
|
close: async () => {
|
|
518
648
|
await handle.close();
|
|
519
649
|
for (const [id, resolve] of closedResolvers) {
|
|
@@ -542,11 +672,13 @@ class NativeClientSession {
|
|
|
542
672
|
#closed = false;
|
|
543
673
|
#requestedCloseInfo = null;
|
|
544
674
|
#strictW3CErrors;
|
|
545
|
-
|
|
675
|
+
#streamOpenWaitTimeoutMs;
|
|
676
|
+
constructor(nativeHandle, readyPromise, closedPromise, strictW3CErrors = false, streamOpenWaitTimeoutMs = DEFAULT_LIMITS.backpressureTimeoutMs) {
|
|
546
677
|
this.#nativeHandle = nativeHandle;
|
|
547
678
|
this.#readyPromise = readyPromise;
|
|
548
679
|
this.#closedPromise = closedPromise.then((info) => normalizeCloseInfo(info, this.#requestedCloseInfo ?? undefined));
|
|
549
680
|
this.#strictW3CErrors = strictW3CErrors;
|
|
681
|
+
this.#streamOpenWaitTimeoutMs = streamOpenWaitTimeoutMs;
|
|
550
682
|
this.#closedPromise.then(() => {
|
|
551
683
|
this.#closed = true;
|
|
552
684
|
});
|
|
@@ -599,11 +731,11 @@ class NativeClientSession {
|
|
|
599
731
|
}
|
|
600
732
|
}
|
|
601
733
|
}
|
|
602
|
-
async createBidirectionalStream() {
|
|
734
|
+
async createBidirectionalStream(options) {
|
|
603
735
|
if (this.#closed)
|
|
604
736
|
throw new WebTransportError(E_SESSION_CLOSED);
|
|
605
737
|
try {
|
|
606
|
-
const nativeStream = await this.#nativeHandle.createBidiStream();
|
|
738
|
+
const nativeStream = (await openStreamWithWait(() => this.#nativeHandle.createBidiStream(), options, this.#streamOpenWaitTimeoutMs, () => this.#closed, undefined, this.#strictW3CErrors));
|
|
607
739
|
return new BidiStream({
|
|
608
740
|
handleId: nativeStream?.id ?? 0,
|
|
609
741
|
nativeHandle: nativeStream,
|
|
@@ -631,11 +763,11 @@ class NativeClientSession {
|
|
|
631
763
|
}
|
|
632
764
|
}
|
|
633
765
|
}
|
|
634
|
-
async createUnidirectionalStream() {
|
|
766
|
+
async createUnidirectionalStream(options) {
|
|
635
767
|
if (this.#closed)
|
|
636
768
|
throw new WebTransportError(E_SESSION_CLOSED);
|
|
637
769
|
try {
|
|
638
|
-
const nativeStream = await this.#nativeHandle.createUniStream();
|
|
770
|
+
const nativeStream = (await openStreamWithWait(() => this.#nativeHandle.createUniStream(), options, this.#streamOpenWaitTimeoutMs, () => this.#closed, undefined, this.#strictW3CErrors));
|
|
639
771
|
return new SendStream({
|
|
640
772
|
handleId: nativeStream?.id ?? 0,
|
|
641
773
|
nativeHandle: nativeStream,
|
|
@@ -670,7 +802,7 @@ class NativeClientSession {
|
|
|
670
802
|
// ---------------------------------------------------------------------------
|
|
671
803
|
// connect
|
|
672
804
|
// ---------------------------------------------------------------------------
|
|
673
|
-
function connectWithNative(native, url, optsJson, handshakeTimeout, strictW3CErrors, setTimer = (cb, ms) => setTimeout(cb, ms), clearTimer = (handle) => clearTimeout(handle)) {
|
|
805
|
+
function connectWithNative(native, url, optsJson, handshakeTimeout, strictW3CErrors, streamOpenWaitTimeoutMs = DEFAULT_LIMITS.backpressureTimeoutMs, setTimer = (cb, ms) => setTimeout(cb, ms), clearTimer = (handle) => clearTimeout(handle)) {
|
|
674
806
|
return new Promise((resolve, reject) => {
|
|
675
807
|
const closedResolvers = new Map();
|
|
676
808
|
let settled = false;
|
|
@@ -736,7 +868,7 @@ function connectWithNative(native, url, optsJson, handshakeTimeout, strictW3CErr
|
|
|
736
868
|
closedResolve = r;
|
|
737
869
|
});
|
|
738
870
|
closedResolvers.set(handle.id, closedResolve);
|
|
739
|
-
settleResolve(new NativeClientSession(handle, Promise.resolve(), closedPromise, strictW3CErrors));
|
|
871
|
+
settleResolve(new NativeClientSession(handle, Promise.resolve(), closedPromise, strictW3CErrors, streamOpenWaitTimeoutMs));
|
|
740
872
|
});
|
|
741
873
|
});
|
|
742
874
|
}
|
|
@@ -793,7 +925,7 @@ export async function connect(url, opts) {
|
|
|
793
925
|
requireUnreliable: opts?.requireUnreliable,
|
|
794
926
|
});
|
|
795
927
|
const handshakeTimeout = mergedLimits.handshakeTimeoutMs;
|
|
796
|
-
return connectWithNative(native, url, optsJson, handshakeTimeout, opts?.strictW3CErrors);
|
|
928
|
+
return connectWithNative(native, url, optsJson, handshakeTimeout, opts?.strictW3CErrors, mergedLimits.backpressureTimeoutMs);
|
|
797
929
|
}
|
|
798
930
|
/** Client pool metrics (hits, misses, evictions). For tests when allowPooling is used. */
|
|
799
931
|
export function clientPoolMetricsSnapshot() {
|
|
@@ -809,16 +941,20 @@ export function clientPoolMetricsSnapshot() {
|
|
|
809
941
|
// ---------------------------------------------------------------------------
|
|
810
942
|
// Browser-style WebTransport facade (Phase P1)
|
|
811
943
|
// ---------------------------------------------------------------------------
|
|
812
|
-
function validateServerCertificateHashes(arr) {
|
|
944
|
+
function validateServerCertificateHashes(arr, strictW3CErrors) {
|
|
813
945
|
for (const entry of arr) {
|
|
814
946
|
if (entry.algorithm !== "sha-256") {
|
|
815
|
-
throw
|
|
947
|
+
throw createMappedError(E_INTERNAL, `E_INTERNAL: serverCertificateHashes only supports algorithm "sha-256", got "${entry.algorithm}"`, strictW3CErrors);
|
|
948
|
+
}
|
|
949
|
+
if (!(entry.value instanceof ArrayBuffer) &&
|
|
950
|
+
!ArrayBuffer.isView(entry.value)) {
|
|
951
|
+
throw createMappedError(E_INTERNAL, "E_INTERNAL: serverCertificateHashes entry value must be BufferSource", strictW3CErrors);
|
|
816
952
|
}
|
|
817
953
|
if (entry.value == null ||
|
|
818
954
|
(typeof entry.value === "object" &&
|
|
819
955
|
"byteLength" in entry &&
|
|
820
956
|
entry.byteLength === 0)) {
|
|
821
|
-
throw
|
|
957
|
+
throw createMappedError(E_INTERNAL, "E_INTERNAL: serverCertificateHashes entry value must be non-empty BufferSource", strictW3CErrors);
|
|
822
958
|
}
|
|
823
959
|
}
|
|
824
960
|
}
|
|
@@ -835,39 +971,39 @@ function bufferSourceToBase64(value) {
|
|
|
835
971
|
}
|
|
836
972
|
const VALID_CONGESTION = new Set(["default", "throughput", "low-latency"]);
|
|
837
973
|
const VALID_DATAGRAMS_READABLE_TYPE = new Set(["bytes", "default"]);
|
|
838
|
-
function validateClientOptions(opts) {
|
|
974
|
+
function validateClientOptions(opts, strictW3CErrors) {
|
|
839
975
|
if (!opts)
|
|
840
976
|
return;
|
|
841
977
|
if (opts.allowPooling !== undefined &&
|
|
842
978
|
typeof opts.allowPooling !== "boolean") {
|
|
843
|
-
throw
|
|
979
|
+
throw createMappedError(E_INTERNAL, "E_INTERNAL: allowPooling must be a boolean", strictW3CErrors);
|
|
844
980
|
}
|
|
845
981
|
if (opts.requireUnreliable !== undefined &&
|
|
846
982
|
typeof opts.requireUnreliable !== "boolean") {
|
|
847
|
-
throw
|
|
983
|
+
throw createMappedError(E_INTERNAL, "E_INTERNAL: requireUnreliable must be a boolean", strictW3CErrors);
|
|
848
984
|
}
|
|
849
985
|
if (opts.congestionControl !== undefined &&
|
|
850
986
|
!VALID_CONGESTION.has(opts.congestionControl)) {
|
|
851
|
-
throw
|
|
987
|
+
throw createMappedError(E_INTERNAL, `E_INTERNAL: congestionControl must be "default", "throughput", or "low-latency", got "${opts.congestionControl}"`, strictW3CErrors);
|
|
852
988
|
}
|
|
853
989
|
if (opts.datagramsReadableType !== undefined &&
|
|
854
990
|
!VALID_DATAGRAMS_READABLE_TYPE.has(opts.datagramsReadableType)) {
|
|
855
|
-
throw
|
|
991
|
+
throw createMappedError(E_INTERNAL, `E_INTERNAL: datagramsReadableType must be "bytes" or "default", got "${opts.datagramsReadableType}"`, strictW3CErrors);
|
|
856
992
|
}
|
|
857
993
|
if (opts.serverCertificateHashes !== undefined) {
|
|
858
994
|
if (!Array.isArray(opts.serverCertificateHashes)) {
|
|
859
|
-
throw
|
|
995
|
+
throw createMappedError(E_INTERNAL, "E_INTERNAL: serverCertificateHashes must be an array", strictW3CErrors);
|
|
860
996
|
}
|
|
861
997
|
if (opts.allowPooling === true) {
|
|
862
998
|
throw new WebTransportError(E_INTERNAL, "E_INTERNAL: serverCertificateHashes cannot be used with allowPooling=true", { browserName: "NotSupportedError" });
|
|
863
999
|
}
|
|
864
|
-
validateServerCertificateHashes(opts.serverCertificateHashes);
|
|
1000
|
+
validateServerCertificateHashes(opts.serverCertificateHashes, strictW3CErrors);
|
|
865
1001
|
}
|
|
866
1002
|
}
|
|
867
1003
|
function mapToClientOptions(opts) {
|
|
868
1004
|
if (!opts)
|
|
869
1005
|
return {};
|
|
870
|
-
validateClientOptions(opts);
|
|
1006
|
+
validateClientOptions(opts, opts.strictW3CErrors);
|
|
871
1007
|
return {
|
|
872
1008
|
tls: opts.tls,
|
|
873
1009
|
limits: opts.limits,
|
|
@@ -1008,13 +1144,13 @@ export class WebTransport {
|
|
|
1008
1144
|
datagramsIn: 0,
|
|
1009
1145
|
};
|
|
1010
1146
|
#congestionControl;
|
|
1147
|
+
#strictW3CErrors = false;
|
|
1011
1148
|
constructor(urlOrSession, options) {
|
|
1012
1149
|
if (typeof urlOrSession === "string") {
|
|
1013
1150
|
this.#datagramsReadableType = options?.datagramsReadableType ?? "default";
|
|
1014
1151
|
const requestedCongestion = options?.congestionControl ?? "default";
|
|
1015
|
-
|
|
1016
|
-
this.#
|
|
1017
|
-
requestedCongestion === "default" ? "default" : "default";
|
|
1152
|
+
this.#congestionControl = requestedCongestion;
|
|
1153
|
+
this.#strictW3CErrors = options?.strictW3CErrors ?? false;
|
|
1018
1154
|
const clientOpts = mapToClientOptions(options);
|
|
1019
1155
|
this.#sessionPromise = connect(urlOrSession, clientOpts);
|
|
1020
1156
|
this.#state = "connecting";
|
|
@@ -1036,8 +1172,9 @@ export class WebTransport {
|
|
|
1036
1172
|
});
|
|
1037
1173
|
}
|
|
1038
1174
|
else {
|
|
1039
|
-
this.#datagramsReadableType = "default";
|
|
1040
|
-
this.#congestionControl = "default";
|
|
1175
|
+
this.#datagramsReadableType = options?.datagramsReadableType ?? "default";
|
|
1176
|
+
this.#congestionControl = options?.congestionControl ?? "default";
|
|
1177
|
+
this.#strictW3CErrors = options?.strictW3CErrors ?? false;
|
|
1041
1178
|
const s = urlOrSession;
|
|
1042
1179
|
this.#sessionPromise = Promise.resolve(s);
|
|
1043
1180
|
this.#session = s;
|
|
@@ -1106,13 +1243,13 @@ export class WebTransport {
|
|
|
1106
1243
|
throw new WebTransportError(E_SESSION_CLOSED);
|
|
1107
1244
|
}
|
|
1108
1245
|
const s = await this.#sessionPromise;
|
|
1109
|
-
const duplex = await s.createBidirectionalStream();
|
|
1246
|
+
const duplex = await s.createBidirectionalStream(options);
|
|
1110
1247
|
return nodeDuplexToWebBidi(duplex, this.#sendScheduler, policy, (bytes) => {
|
|
1111
1248
|
this.#connStats.bytesSent += bytes;
|
|
1112
1249
|
this._recordSendGroupBytes(policy.groupId, bytes);
|
|
1113
1250
|
}, (bytes) => {
|
|
1114
1251
|
this.#connStats.bytesReceived += bytes;
|
|
1115
|
-
});
|
|
1252
|
+
}, this.#strictW3CErrors);
|
|
1116
1253
|
}
|
|
1117
1254
|
/**
|
|
1118
1255
|
* Create a unidirectional send stream (WritableStream).
|
|
@@ -1126,11 +1263,11 @@ export class WebTransport {
|
|
|
1126
1263
|
throw new WebTransportError(E_SESSION_CLOSED);
|
|
1127
1264
|
}
|
|
1128
1265
|
const s = await this.#sessionPromise;
|
|
1129
|
-
const writable = await s.createUnidirectionalStream();
|
|
1266
|
+
const writable = await s.createUnidirectionalStream(options);
|
|
1130
1267
|
return nodeWritableToWebWritable(writable, this.#sendScheduler, policy, (bytes) => {
|
|
1131
1268
|
this.#connStats.bytesSent += bytes;
|
|
1132
1269
|
this._recordSendGroupBytes(policy.groupId, bytes);
|
|
1133
|
-
});
|
|
1270
|
+
}, this.#strictW3CErrors);
|
|
1134
1271
|
}
|
|
1135
1272
|
/**
|
|
1136
1273
|
* Get connection stats (W3C WebTransportConnectionStats).
|
|
@@ -1171,8 +1308,10 @@ export class WebTransport {
|
|
|
1171
1308
|
else {
|
|
1172
1309
|
// Still connecting: absorb eventual connect failure to prevent unhandled rejection (S4).
|
|
1173
1310
|
this.#ready.catch((err) => {
|
|
1174
|
-
|
|
1175
|
-
|
|
1311
|
+
if (!SUPPRESS_READY_REJECTION_WARN) {
|
|
1312
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1313
|
+
console.warn(`[webtransport] ready rejection observed after close() during connect: ${msg}`);
|
|
1314
|
+
}
|
|
1176
1315
|
});
|
|
1177
1316
|
}
|
|
1178
1317
|
}
|
|
@@ -1184,6 +1323,9 @@ export class WebTransport {
|
|
|
1184
1323
|
_getState() {
|
|
1185
1324
|
return this.#state;
|
|
1186
1325
|
}
|
|
1326
|
+
_isStrictW3CErrors() {
|
|
1327
|
+
return this.#strictW3CErrors;
|
|
1328
|
+
}
|
|
1187
1329
|
_resolveSendPolicy(options) {
|
|
1188
1330
|
const sendOrder = options?.sendOrder ?? 0;
|
|
1189
1331
|
if (!Number.isInteger(sendOrder)) {
|
|
@@ -1363,7 +1505,7 @@ function createIncomingBidiStreams(wt) {
|
|
|
1363
1505
|
for await (const duplex of s.incomingBidirectionalStreams()) {
|
|
1364
1506
|
controller.enqueue(await nodeDuplexToWebBidi(duplex, undefined, undefined, undefined, (bytes) => {
|
|
1365
1507
|
wt._recordIncomingStreamBytes(bytes);
|
|
1366
|
-
}));
|
|
1508
|
+
}, wt._isStrictW3CErrors()));
|
|
1367
1509
|
}
|
|
1368
1510
|
controller.close();
|
|
1369
1511
|
},
|
|
@@ -1376,15 +1518,15 @@ function createIncomingUniStreams(wt) {
|
|
|
1376
1518
|
for await (const readable of s.incomingUnidirectionalStreams()) {
|
|
1377
1519
|
controller.enqueue(nodeReadableToWebReadable(readable, (bytes) => {
|
|
1378
1520
|
wt._recordIncomingStreamBytes(bytes);
|
|
1379
|
-
}));
|
|
1521
|
+
}, wt._isStrictW3CErrors()));
|
|
1380
1522
|
}
|
|
1381
1523
|
controller.close();
|
|
1382
1524
|
},
|
|
1383
1525
|
});
|
|
1384
1526
|
}
|
|
1385
|
-
function nodeDuplexToWebBidi(duplex, scheduler, policy, onWriteBytes, onReadBytes) {
|
|
1386
|
-
const readable = nodeReadableToWebReadable(duplex, onReadBytes);
|
|
1387
|
-
const writable = nodeWritableToWebWritable(duplex, scheduler, policy, onWriteBytes);
|
|
1527
|
+
function nodeDuplexToWebBidi(duplex, scheduler, policy, onWriteBytes, onReadBytes, strictW3CErrors = false) {
|
|
1528
|
+
const readable = nodeReadableToWebReadable(duplex, onReadBytes, strictW3CErrors);
|
|
1529
|
+
const writable = nodeWritableToWebWritable(duplex, scheduler, policy, onWriteBytes, strictW3CErrors);
|
|
1388
1530
|
return Promise.resolve({ readable, writable });
|
|
1389
1531
|
}
|
|
1390
1532
|
/** Extract QUIC application error code from abort/cancel reason. */
|
|
@@ -1401,17 +1543,22 @@ function extractStreamErrorCode(reason) {
|
|
|
1401
1543
|
}
|
|
1402
1544
|
return 0;
|
|
1403
1545
|
}
|
|
1404
|
-
function nodeReadableToWebReadable(r, onReadBytes) {
|
|
1546
|
+
function nodeReadableToWebReadable(r, onReadBytes, strictW3CErrors = false) {
|
|
1405
1547
|
const stopSendable = r;
|
|
1406
1548
|
return new ReadableStream({
|
|
1407
1549
|
async start(controller) {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
onReadBytes
|
|
1412
|
-
|
|
1550
|
+
try {
|
|
1551
|
+
for await (const chunk of r) {
|
|
1552
|
+
const bytes = chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk);
|
|
1553
|
+
if (onReadBytes)
|
|
1554
|
+
onReadBytes(bytes.byteLength);
|
|
1555
|
+
controller.enqueue(bytes);
|
|
1556
|
+
}
|
|
1557
|
+
controller.close();
|
|
1558
|
+
}
|
|
1559
|
+
catch (err) {
|
|
1560
|
+
controller.error(toWebTransportError(err, strictW3CErrors));
|
|
1413
1561
|
}
|
|
1414
|
-
controller.close();
|
|
1415
1562
|
},
|
|
1416
1563
|
cancel(reason) {
|
|
1417
1564
|
const fn = stopSendable[WT_STOP_SENDING];
|
|
@@ -1420,25 +1567,36 @@ function nodeReadableToWebReadable(r, onReadBytes) {
|
|
|
1420
1567
|
},
|
|
1421
1568
|
});
|
|
1422
1569
|
}
|
|
1423
|
-
function nodeWritableToWebWritable(w, scheduler, policy, onWriteBytes) {
|
|
1570
|
+
function nodeWritableToWebWritable(w, scheduler, policy, onWriteBytes, strictW3CErrors = false) {
|
|
1424
1571
|
const resettable = w;
|
|
1425
1572
|
return new WritableStream({
|
|
1426
1573
|
async write(chunk) {
|
|
1427
1574
|
const run = () => new Promise((resolve, reject) => {
|
|
1428
1575
|
w.write(Buffer.from(chunk), (err) => err ? reject(err) : resolve());
|
|
1429
1576
|
});
|
|
1430
|
-
|
|
1431
|
-
|
|
1577
|
+
try {
|
|
1578
|
+
if (scheduler && policy) {
|
|
1579
|
+
await scheduler.enqueue(policy, run);
|
|
1580
|
+
}
|
|
1581
|
+
else {
|
|
1582
|
+
await run();
|
|
1583
|
+
}
|
|
1432
1584
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1585
|
+
catch (err) {
|
|
1586
|
+
throw toWebTransportError(err, strictW3CErrors);
|
|
1435
1587
|
}
|
|
1436
1588
|
if (onWriteBytes)
|
|
1437
1589
|
onWriteBytes(chunk.byteLength);
|
|
1438
1590
|
},
|
|
1439
1591
|
close() {
|
|
1440
1592
|
return new Promise((resolve, reject) => {
|
|
1441
|
-
w.end((err) =>
|
|
1593
|
+
w.end((err) => {
|
|
1594
|
+
if (err) {
|
|
1595
|
+
reject(toWebTransportError(err, strictW3CErrors));
|
|
1596
|
+
return;
|
|
1597
|
+
}
|
|
1598
|
+
resolve();
|
|
1599
|
+
});
|
|
1442
1600
|
});
|
|
1443
1601
|
},
|
|
1444
1602
|
abort(reason) {
|
|
@@ -1452,7 +1610,7 @@ function createNativeClientSessionForTests(nativeHandle, strictW3CErrors = false
|
|
|
1452
1610
|
return new NativeClientSession(nativeHandle, Promise.resolve(), new Promise(() => { }), strictW3CErrors);
|
|
1453
1611
|
}
|
|
1454
1612
|
function createNativeServerSessionForTests(nativeHandle) {
|
|
1455
|
-
return new NativeServerSession(nativeHandle, new Promise(() => { }));
|
|
1613
|
+
return new NativeServerSession(nativeHandle, new Promise(() => { }), DEFAULT_LIMITS.backpressureTimeoutMs);
|
|
1456
1614
|
}
|
|
1457
1615
|
export const __TESTING__ = {
|
|
1458
1616
|
createNativeClientSessionForTests,
|
package/dist/streams.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ type StreamHandleId = number;
|
|
|
31
31
|
export interface BidiStreamOptions extends DuplexOptions {
|
|
32
32
|
handleId: StreamHandleId;
|
|
33
33
|
nativeHandle?: any;
|
|
34
|
+
strictStreamErrors?: boolean;
|
|
34
35
|
}
|
|
35
36
|
export declare class BidiStream extends Duplex implements Resettable, StopSendable {
|
|
36
37
|
#private;
|
|
@@ -46,6 +47,7 @@ export declare class BidiStream extends Duplex implements Resettable, StopSendab
|
|
|
46
47
|
export interface SendStreamOptions extends WritableOptions {
|
|
47
48
|
handleId: StreamHandleId;
|
|
48
49
|
nativeHandle?: any;
|
|
50
|
+
strictStreamErrors?: boolean;
|
|
49
51
|
}
|
|
50
52
|
export declare class SendStream extends Writable implements Resettable {
|
|
51
53
|
#private;
|
|
@@ -59,6 +61,7 @@ export declare class SendStream extends Writable implements Resettable {
|
|
|
59
61
|
export interface RecvStreamOptions extends ReadableOptions {
|
|
60
62
|
handleId: StreamHandleId;
|
|
61
63
|
nativeHandle?: any;
|
|
64
|
+
strictStreamErrors?: boolean;
|
|
62
65
|
}
|
|
63
66
|
export declare class RecvStream extends Readable implements StopSendable {
|
|
64
67
|
#private;
|
package/dist/streams.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streams.d.ts","sourceRoot":"","sources":["../src/streams.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EACX,aAAa,EACb,eAAe,EACf,eAAe,EACf,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,MAA2B,CAAC;AAC1D;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,MAAkC,CAAC;AAExE,+CAA+C;AAC/C,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAC7D,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG;IAAE,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAKtE,KAAK,cAAc,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"streams.d.ts","sourceRoot":"","sources":["../src/streams.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EACX,aAAa,EACb,eAAe,EACf,eAAe,EACf,MAAM,aAAa,CAAC;AAErB;;;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kBP,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;CAGtC"}
|
package/dist/streams.js
CHANGED
|
@@ -18,10 +18,16 @@ export const WT_RESET = Symbol("WT_RESET");
|
|
|
18
18
|
* @example `(stream as StopSendable)[WT_STOP_SENDING](code)`
|
|
19
19
|
*/
|
|
20
20
|
export const WT_STOP_SENDING = Symbol("WT_STOP_SENDING");
|
|
21
|
+
const DEFAULT_STRICT_STREAM_ERRORS = process.env.WEBTRANSPORT_STRICT_STREAM_ERRORS === "1";
|
|
22
|
+
const SUPPRESS_UNHANDLED_STREAM_ERROR_LOGS = process.env.WEBTRANSPORT_SUPPRESS_UNHANDLED_STREAM_ERROR_LOGS === "1";
|
|
23
|
+
function normalizeError(err) {
|
|
24
|
+
return err instanceof Error ? err : new Error(String(err));
|
|
25
|
+
}
|
|
21
26
|
export class BidiStream extends Duplex {
|
|
22
27
|
_handleId;
|
|
23
28
|
#nativeHandle;
|
|
24
29
|
#destroyed = false;
|
|
30
|
+
#strictStreamErrors = DEFAULT_STRICT_STREAM_ERRORS;
|
|
25
31
|
constructor(opts) {
|
|
26
32
|
super({
|
|
27
33
|
...opts,
|
|
@@ -32,6 +38,20 @@ export class BidiStream extends Duplex {
|
|
|
32
38
|
});
|
|
33
39
|
this._handleId = opts.handleId;
|
|
34
40
|
this.#nativeHandle = opts.nativeHandle;
|
|
41
|
+
this.#strictStreamErrors =
|
|
42
|
+
opts.strictStreamErrors ?? DEFAULT_STRICT_STREAM_ERRORS;
|
|
43
|
+
this.on("error", (err) => {
|
|
44
|
+
if (this.listenerCount("error") > 1)
|
|
45
|
+
return;
|
|
46
|
+
const e = normalizeError(err);
|
|
47
|
+
if (!SUPPRESS_UNHANDLED_STREAM_ERROR_LOGS) {
|
|
48
|
+
console.warn(`[webtransport] unhandled bidi stream error: ${e.message}`);
|
|
49
|
+
}
|
|
50
|
+
if (this.#strictStreamErrors)
|
|
51
|
+
queueMicrotask(() => {
|
|
52
|
+
throw e;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
35
55
|
}
|
|
36
56
|
// -- Node stream overrides -----------------------
|
|
37
57
|
_read(_size) {
|
|
@@ -60,18 +80,39 @@ export class BidiStream extends Duplex {
|
|
|
60
80
|
.catch(callback);
|
|
61
81
|
}
|
|
62
82
|
_final(callback) {
|
|
63
|
-
this.#nativeHandle
|
|
64
|
-
|
|
83
|
+
const h = this.#nativeHandle;
|
|
84
|
+
if (!h || this.#destroyed) {
|
|
85
|
+
callback();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const finishFn = h.finishWait ?? h.finish;
|
|
90
|
+
if (typeof finishFn !== "function") {
|
|
91
|
+
callback();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const ret = finishFn.call(h);
|
|
95
|
+
if (ret && typeof ret.then === "function") {
|
|
96
|
+
ret.then(() => callback(), (err) => callback(err));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
callback();
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
callback(err);
|
|
103
|
+
}
|
|
65
104
|
}
|
|
66
105
|
_destroy(error, callback) {
|
|
67
106
|
if (!this.#destroyed) {
|
|
68
107
|
this.#destroyed = true;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
108
|
+
if (error) {
|
|
109
|
+
try {
|
|
110
|
+
this.#nativeHandle?.reset?.(0);
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
114
|
+
console.warn(`[webtransport] bidi stream reset on destroy failed: ${msg}`);
|
|
115
|
+
}
|
|
75
116
|
}
|
|
76
117
|
this.#nativeHandle = null;
|
|
77
118
|
}
|
|
@@ -90,6 +131,7 @@ export class SendStream extends Writable {
|
|
|
90
131
|
_handleId;
|
|
91
132
|
#nativeHandle;
|
|
92
133
|
#destroyed = false;
|
|
134
|
+
#strictStreamErrors = DEFAULT_STRICT_STREAM_ERRORS;
|
|
93
135
|
constructor(opts) {
|
|
94
136
|
super({
|
|
95
137
|
...opts,
|
|
@@ -98,6 +140,20 @@ export class SendStream extends Writable {
|
|
|
98
140
|
});
|
|
99
141
|
this._handleId = opts.handleId;
|
|
100
142
|
this.#nativeHandle = opts.nativeHandle;
|
|
143
|
+
this.#strictStreamErrors =
|
|
144
|
+
opts.strictStreamErrors ?? DEFAULT_STRICT_STREAM_ERRORS;
|
|
145
|
+
this.on("error", (err) => {
|
|
146
|
+
if (this.listenerCount("error") > 1)
|
|
147
|
+
return;
|
|
148
|
+
const e = normalizeError(err);
|
|
149
|
+
if (!SUPPRESS_UNHANDLED_STREAM_ERROR_LOGS) {
|
|
150
|
+
console.warn(`[webtransport] unhandled unidirectional send stream error: ${e.message}`);
|
|
151
|
+
}
|
|
152
|
+
if (this.#strictStreamErrors)
|
|
153
|
+
queueMicrotask(() => {
|
|
154
|
+
throw e;
|
|
155
|
+
});
|
|
156
|
+
});
|
|
101
157
|
}
|
|
102
158
|
_write(chunk, _encoding, callback) {
|
|
103
159
|
const h = this.#nativeHandle;
|
|
@@ -110,18 +166,39 @@ export class SendStream extends Writable {
|
|
|
110
166
|
.catch(callback);
|
|
111
167
|
}
|
|
112
168
|
_final(callback) {
|
|
113
|
-
this.#nativeHandle
|
|
114
|
-
|
|
169
|
+
const h = this.#nativeHandle;
|
|
170
|
+
if (!h || this.#destroyed) {
|
|
171
|
+
callback();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
const finishFn = h.finishWait ?? h.finish;
|
|
176
|
+
if (typeof finishFn !== "function") {
|
|
177
|
+
callback();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const ret = finishFn.call(h);
|
|
181
|
+
if (ret && typeof ret.then === "function") {
|
|
182
|
+
ret.then(() => callback(), (err) => callback(err));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
callback();
|
|
186
|
+
}
|
|
187
|
+
catch (err) {
|
|
188
|
+
callback(err);
|
|
189
|
+
}
|
|
115
190
|
}
|
|
116
191
|
_destroy(error, callback) {
|
|
117
192
|
if (!this.#destroyed) {
|
|
118
193
|
this.#destroyed = true;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
194
|
+
if (error) {
|
|
195
|
+
try {
|
|
196
|
+
this.#nativeHandle?.reset?.(0);
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
200
|
+
console.warn(`[webtransport] unidirectional send stream reset on destroy failed: ${msg}`);
|
|
201
|
+
}
|
|
125
202
|
}
|
|
126
203
|
this.#nativeHandle = null;
|
|
127
204
|
}
|
|
@@ -136,6 +213,7 @@ export class RecvStream extends Readable {
|
|
|
136
213
|
_handleId;
|
|
137
214
|
#nativeHandle;
|
|
138
215
|
#destroyed = false;
|
|
216
|
+
#strictStreamErrors = DEFAULT_STRICT_STREAM_ERRORS;
|
|
139
217
|
constructor(opts) {
|
|
140
218
|
super({
|
|
141
219
|
...opts,
|
|
@@ -144,6 +222,20 @@ export class RecvStream extends Readable {
|
|
|
144
222
|
});
|
|
145
223
|
this._handleId = opts.handleId;
|
|
146
224
|
this.#nativeHandle = opts.nativeHandle;
|
|
225
|
+
this.#strictStreamErrors =
|
|
226
|
+
opts.strictStreamErrors ?? DEFAULT_STRICT_STREAM_ERRORS;
|
|
227
|
+
this.on("error", (err) => {
|
|
228
|
+
if (this.listenerCount("error") > 1)
|
|
229
|
+
return;
|
|
230
|
+
const e = normalizeError(err);
|
|
231
|
+
if (!SUPPRESS_UNHANDLED_STREAM_ERROR_LOGS) {
|
|
232
|
+
console.warn(`[webtransport] unhandled unidirectional recv stream error: ${e.message}`);
|
|
233
|
+
}
|
|
234
|
+
if (this.#strictStreamErrors)
|
|
235
|
+
queueMicrotask(() => {
|
|
236
|
+
throw e;
|
|
237
|
+
});
|
|
238
|
+
});
|
|
147
239
|
}
|
|
148
240
|
_read(_size) {
|
|
149
241
|
const h = this.#nativeHandle;
|
|
@@ -163,12 +255,14 @@ export class RecvStream extends Readable {
|
|
|
163
255
|
_destroy(error, callback) {
|
|
164
256
|
if (!this.#destroyed) {
|
|
165
257
|
this.#destroyed = true;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
258
|
+
if (error) {
|
|
259
|
+
try {
|
|
260
|
+
this.#nativeHandle?.stopSending?.(0);
|
|
261
|
+
}
|
|
262
|
+
catch (err) {
|
|
263
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
264
|
+
console.warn(`[webtransport] unidirectional recv stream stopSending on destroy failed: ${msg}`);
|
|
265
|
+
}
|
|
172
266
|
}
|
|
173
267
|
this.#nativeHandle = null;
|
|
174
268
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webtransport-bun/webtransport",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Production-focused WebTransport for Bun, Node, and Deno with datagrams and streams via a Rust napi-rs addon",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
},
|
|
42
42
|
"os": [
|
|
43
43
|
"darwin",
|
|
44
|
-
"linux"
|
|
44
|
+
"linux",
|
|
45
|
+
"win32"
|
|
45
46
|
],
|
|
46
47
|
"cpu": [
|
|
47
48
|
"arm64",
|
|
@@ -51,12 +52,13 @@
|
|
|
51
52
|
"access": "public"
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
54
|
-
"clean": "
|
|
55
|
+
"clean": "bun -e \"import { rm } from 'node:fs/promises'; await rm('dist', { recursive: true, force: true });\"",
|
|
55
56
|
"build": "tsc -p tsconfig.build.json",
|
|
56
|
-
"prebuild:native": "cd ../.. && bun
|
|
57
|
-
"prebuild:
|
|
57
|
+
"prebuild:native": "cd ../.. && bun scripts/copy-prebuilds.ts",
|
|
58
|
+
"prebuild:build-and-copy": "cd ../.. && bun run build:native && bun scripts/copy-prebuilds.ts",
|
|
59
|
+
"prebuild:checksums": "cd ../.. && bun scripts/write-sha256sums.ts packages/webtransport/prebuilds",
|
|
58
60
|
"pack:check": "npm pack --dry-run",
|
|
59
|
-
"prepublishOnly": "npm run clean && npm run build && npm run prebuild:
|
|
61
|
+
"prepublishOnly": "npm run clean && npm run build && npm run prebuild:build-and-copy && npm run prebuild:checksums && npm run pack:check",
|
|
60
62
|
"test": "bun test",
|
|
61
63
|
"typecheck": "tsc --noEmit"
|
|
62
64
|
}
|
package/prebuilds/SHA256SUMS
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
b1897131089cfd9ba4260592d3536e9b4423c0d16b67d83f2d99ca2d7321e566 webtransport-native.darwin-arm64.node
|
|
2
|
+
ab5cb9d115a02fa22747d92325f29c0d6179f7b2d1dd0519e416169f8838976d webtransport-native.darwin-x64.node
|
|
3
|
+
e4d5a206a6f8e304503a39b5ad94aea1866262797509083b528fdbee27ba3581 webtransport-native.linux-x64-gnu.node
|
|
4
|
+
0878e95ee0be5d792fbaeaf6b1187de39dd23cb573bebc76a1d2c58e24c9b62c webtransport-native.win32-x64-msvc.node
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|