rwebtransport 0.2.2 → 0.2.5

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.
Files changed (99) hide show
  1. package/Cargo.lock +523 -140
  2. package/Cargo.toml +5 -5
  3. package/README.md +8 -4
  4. package/crates/echo-server/src/bin/gen-test-cert.rs +1 -1
  5. package/crates/native/Cargo.toml +2 -0
  6. package/crates/native/src/config.rs +69 -8
  7. package/crates/native/src/driver.rs +253 -90
  8. package/crates/native/src/lib.rs +80 -57
  9. package/crates/native/src/parser_memory.rs +203 -0
  10. package/crates/native/src/server.rs +215 -183
  11. package/crates/native/src/session.rs +1341 -243
  12. package/crates/native/src/test_support.rs +119 -0
  13. package/crates/wtcore/Cargo.toml +1 -0
  14. package/crates/wtcore/src/h3.rs +250 -46
  15. package/dist/index.js +218 -75
  16. package/dist/index.js.map +7 -1
  17. package/dist/index.mjs +214 -69
  18. package/dist/index.mjs.map +7 -1
  19. package/dist/native.d.ts +10 -4
  20. package/dist/server.d.ts +1 -0
  21. package/package.json +84 -78
  22. package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
  23. package/prebuilds/linux-arm64/rwebtransport.node +0 -0
  24. package/prebuilds/linux-x64/rwebtransport.node +0 -0
  25. package/prebuilds/win32-x64/rwebtransport.node +0 -0
  26. package/scripts/build-linux-prebuilt.sh +46 -0
  27. package/scripts/build-ts.js +41 -0
  28. package/scripts/build.js +10 -3
  29. package/vendor/quiche/AGENTS.md +10 -0
  30. package/vendor/quiche/Cargo.lock +239 -248
  31. package/vendor/quiche/Cargo.toml +23 -10
  32. package/vendor/quiche/examples/Makefile +4 -4
  33. package/vendor/quiche/examples/client.rs +10 -28
  34. package/vendor/quiche/examples/http3-client.rs +20 -34
  35. package/vendor/quiche/examples/http3-server.rs +47 -78
  36. package/vendor/quiche/examples/server.rs +19 -49
  37. package/vendor/quiche/include/quiche.h +35 -4
  38. package/vendor/quiche/src/build.rs +17 -0
  39. package/vendor/quiche/src/cid.rs +129 -61
  40. package/vendor/quiche/src/crypto/boringssl.rs +98 -86
  41. package/vendor/quiche/src/crypto/mod.rs +64 -77
  42. package/vendor/quiche/src/dgram.rs +2 -3
  43. package/vendor/quiche/src/error.rs +22 -20
  44. package/vendor/quiche/src/ffi.rs +558 -280
  45. package/vendor/quiche/src/flowcontrol.rs +0 -7
  46. package/vendor/quiche/src/frame.rs +134 -135
  47. package/vendor/quiche/src/h3/ffi.rs +73 -60
  48. package/vendor/quiche/src/h3/frame.rs +70 -90
  49. package/vendor/quiche/src/h3/mod.rs +1024 -593
  50. package/vendor/quiche/src/h3/qpack/decoder.rs +248 -34
  51. package/vendor/quiche/src/h3/qpack/dynamic_table.rs +859 -0
  52. package/vendor/quiche/src/h3/qpack/encoder.rs +14 -17
  53. package/vendor/quiche/src/h3/qpack/mod.rs +48 -0
  54. package/vendor/quiche/src/h3/qpack/static_table.rs +86 -73
  55. package/vendor/quiche/src/h3/stream.rs +1009 -194
  56. package/vendor/quiche/src/lib.rs +1361 -1195
  57. package/vendor/quiche/src/minmax.rs +2 -6
  58. package/vendor/quiche/src/packet.rs +420 -552
  59. package/vendor/quiche/src/path.rs +202 -72
  60. package/vendor/quiche/src/pmtud.rs +18 -16
  61. package/vendor/quiche/src/ranges.rs +184 -82
  62. package/vendor/quiche/src/recovery/AGENTS.md +5 -2
  63. package/vendor/quiche/src/recovery/bandwidth.rs +59 -40
  64. package/vendor/quiche/src/recovery/bytes_in_flight.rs +2 -2
  65. package/vendor/quiche/src/recovery/congestion/cubic.rs +38 -47
  66. package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +54 -60
  67. package/vendor/quiche/src/recovery/congestion/hystart.rs +6 -10
  68. package/vendor/quiche/src/recovery/congestion/mod.rs +110 -42
  69. package/vendor/quiche/src/recovery/congestion/prr.rs +4 -1
  70. package/vendor/quiche/src/recovery/congestion/recovery.rs +91 -95
  71. package/vendor/quiche/src/recovery/congestion/reno.rs +17 -12
  72. package/vendor/quiche/src/recovery/congestion/test_sender.rs +8 -27
  73. package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +159 -247
  74. package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +9 -14
  75. package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +18 -15
  76. package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +43 -28
  77. package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +349 -76
  78. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +147 -195
  79. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +29 -27
  80. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min.rs +180 -0
  81. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/global_min_tests.rs +221 -0
  82. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm.rs +395 -0
  83. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/hmm_tests.rs +473 -0
  84. package/vendor/quiche/src/recovery/gcongestion/bbr2/rtt_jump_detector/mod.rs +175 -0
  85. package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +33 -26
  86. package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +107 -60
  87. package/vendor/quiche/src/recovery/gcongestion/mod.rs +64 -11
  88. package/vendor/quiche/src/recovery/gcongestion/pacer.rs +34 -25
  89. package/vendor/quiche/src/recovery/gcongestion/recovery.rs +81 -86
  90. package/vendor/quiche/src/recovery/mod.rs +414 -173
  91. package/vendor/quiche/src/recovery/rtt.rs +8 -5
  92. package/vendor/quiche/src/stream/mod.rs +864 -133
  93. package/vendor/quiche/src/stream/recv_buf.rs +476 -172
  94. package/vendor/quiche/src/stream/send_buf.rs +343 -81
  95. package/vendor/quiche/src/test_utils.rs +78 -64
  96. package/vendor/quiche/src/tests.rs +2559 -1335
  97. package/vendor/quiche/src/tls/boringssl.rs +60 -63
  98. package/vendor/quiche/src/tls/mod.rs +146 -193
  99. package/vendor/quiche/src/transport_params.rs +87 -103
package/dist/native.d.ts CHANGED
@@ -13,6 +13,7 @@ export declare enum NativeEventType {
13
13
  Closed = "closed",
14
14
  Error = "error",
15
15
  Datagram = "datagram",
16
+ DatagramSize = "datagramSize",
16
17
  Stream = "stream",
17
18
  StreamData = "streamData",
18
19
  StreamFin = "streamFin",
@@ -92,6 +93,7 @@ export interface NativeStreamOpenedEvent {
92
93
  export interface NativeWriteAckEvent {
93
94
  type: NativeEventType.WriteAck;
94
95
  requestId: number;
96
+ accepted: boolean;
95
97
  }
96
98
  export interface NativeDatagramAckEvent {
97
99
  type: NativeEventType.DatagramAck;
@@ -116,7 +118,10 @@ export interface NativeKeyingMaterialEvent {
116
118
  ok: boolean;
117
119
  data?: Uint8Array;
118
120
  }
119
- export type NativeEvent = NativeReadyEvent | NativeDrainingEvent | NativeServerReadyEvent | NativeClosedEvent | NativeErrorEvent | NativeDatagramEvent | NativeStreamEvent | NativeStreamDataEvent | NativeStreamFinEvent | NativeStreamResetEvent | NativeStreamStopSendingEvent | NativeStreamOpenedEvent | NativeWriteAckEvent | NativeDatagramAckEvent | NativeStatsEvent | NativeKeyingMaterialEvent;
121
+ export type NativeEvent = NativeReadyEvent | NativeDrainingEvent | NativeServerReadyEvent | NativeClosedEvent | NativeErrorEvent | NativeDatagramEvent | {
122
+ type: NativeEventType.DatagramSize;
123
+ size: number;
124
+ } | NativeStreamEvent | NativeStreamDataEvent | NativeStreamFinEvent | NativeStreamResetEvent | NativeStreamStopSendingEvent | NativeStreamOpenedEvent | NativeWriteAckEvent | NativeDatagramAckEvent | NativeStatsEvent | NativeKeyingMaterialEvent;
120
125
  export interface NativeAddon {
121
126
  connect(url: string, hashes: Uint8Array[], insecure: boolean, origin: string | null, headerNames: string[], headerValues: string[], protocols: string[], onEvent: (ev: NativeEvent) => void): NativeHandle;
122
127
  openStream(handle: NativeHandle, bidi: boolean, requestId: number): void;
@@ -142,7 +147,6 @@ export interface NativeAddon {
142
147
  serverStopSending(handle: NativeServerHandle, session: number, streamId: number, code: number): void;
143
148
  serverSetPaused(handle: NativeServerHandle, session: number, streamId: number, paused: boolean): void;
144
149
  serverSendDatagram(handle: NativeServerHandle, session: number, bytes: Uint8Array, requestId: number): void;
145
- serverMaxDatagramSize(handle: NativeServerHandle): number;
146
150
  serverCloseSession(handle: NativeServerHandle, session: number, code: number, reason: Uint8Array): void;
147
151
  serverDrain(handle: NativeServerHandle, session: number): void;
148
152
  serverGetStats(handle: NativeServerHandle, session: number, requestId: number): void;
@@ -200,7 +204,7 @@ export interface SessionTransport {
200
204
  stopSending(streamId: number, code: number): void;
201
205
  setPaused(streamId: number, paused: boolean): void;
202
206
  sendDatagram(bytes: Uint8Array, requestId: number): void;
203
- maxDatagramSize(): number;
207
+ maxDatagramSize?(): number;
204
208
  closeSession(code: number, reason: Uint8Array): void;
205
209
  drain(): void;
206
210
  getStats(requestId: number): void;
@@ -226,6 +230,7 @@ export declare class SessionCore {
226
230
  private lastStats;
227
231
  private cachedProtocol;
228
232
  private cachedResponseHeaders;
233
+ private advertisedDatagramSize?;
229
234
  readonly ready: Deferred<void>;
230
235
  readonly closed: Deferred<WebTransportCloseInfo>;
231
236
  readonly draining: Deferred<void>;
@@ -237,11 +242,13 @@ export declare class SessionCore {
237
242
  write(streamId: number, chunk: Uint8Array): Promise<void>;
238
243
  finStream(streamId: number): void;
239
244
  resetStream(streamId: number, code: number): void;
245
+ private rejectStreamWrites;
240
246
  stopSending(streamId: number, code: number): void;
241
247
  setPaused(streamId: number, paused: boolean): void;
242
248
  sendDatagram(chunk: Uint8Array): Promise<boolean>;
243
249
  maxDatagramSize(): number;
244
250
  close(code: number, reason: string): void;
251
+ abort(message: string): void;
245
252
  drain(): void;
246
253
  getStats(): Promise<WebTransportConnectionStats>;
247
254
  exportKeyingMaterial(label: Uint8Array, context: Uint8Array, length: number): Promise<Uint8Array>;
@@ -275,7 +282,6 @@ export declare class ServerTransport implements SessionTransport {
275
282
  stopSending(streamId: number, code: number): void;
276
283
  setPaused(streamId: number, paused: boolean): void;
277
284
  sendDatagram(bytes: Uint8Array, requestId: number): void;
278
- maxDatagramSize(): number;
279
285
  closeSession(code: number, reason: Uint8Array): void;
280
286
  drain(): void;
281
287
  getStats(requestId: number): void;
package/dist/server.d.ts CHANGED
@@ -39,6 +39,7 @@ export declare class WebTransportServer {
39
39
  private incomingController;
40
40
  private boundPort;
41
41
  private closeCalled;
42
+ private incomingCancelled;
42
43
  readonly incomingSessions: ReadableStream<WebTransportServerSession>;
43
44
  constructor(options: WebTransportServerOptions);
44
45
  get ready(): Promise<void>;
package/package.json CHANGED
@@ -1,80 +1,86 @@
1
1
  {
2
- "name": "rwebtransport",
3
- "version": "0.2.2",
4
- "description": "A fully-compatible WebTransport client and server for Node.js, powered by Cloudflare quiche + BoringSSL via neon.",
5
- "author": "Dacely Cloud",
6
- "homepage": "https://github.com/dacely-cloud/rwebtransport#readme",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/dacely-cloud/rwebtransport.git"
10
- },
11
- "bugs": {
12
- "url": "https://github.com/dacely-cloud/rwebtransport/issues"
13
- },
14
- "type": "commonjs",
15
- "main": "./dist/index.js",
16
- "module": "./dist/index.mjs",
17
- "types": "./dist/index.d.ts",
18
- "exports": {
19
- ".": {
20
- "types": "./dist/index.d.ts",
21
- "import": "./dist/index.mjs",
22
- "require": "./dist/index.js"
23
- }
24
- },
25
- "files": [
26
- "dist",
27
- "prebuilds",
28
- "scripts",
29
- "crates",
30
- "vendor",
31
- "Cargo.toml",
32
- "Cargo.lock",
33
- "README.md",
34
- "NOTICE"
35
- ],
36
- "engines": {
37
- "node": ">=24 <25 || >=26 <27"
38
- },
39
- "scripts": {
40
- "build": "npm run build:rust && npm run build:ts",
41
- "build:rust": "node scripts/build.js",
42
- "build:rust:debug": "node scripts/build.js --debug",
43
- "build:ts": "tsup src/index.ts --format cjs,esm --sourcemap --clean --shims --out-dir dist && tsc -p tsconfig.build.json",
44
- "build:echo": "cargo build --release -p rwebtransport-echo-server",
45
- "setup:windows": "powershell -ExecutionPolicy Bypass -File scripts/setup-windows.ps1",
46
- "setup:unix": "bash scripts/setup-unix.sh",
47
- "postinstall": "node scripts/postinstall.js",
48
- "pretest": "npm run build:rust && npm run build:ts && npm run build:echo",
49
- "test": "vitest run",
50
- "test:watch": "vitest",
51
- "typecheck": "tsc --noEmit",
52
- "lint": "eslint .",
53
- "lint:fix": "eslint . --fix",
54
- "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
55
- "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\""
56
- },
57
- "devDependencies": {
58
- "@eslint/js": "^10.0.1",
59
- "@types/node": "^26.1.1",
60
- "@vitest/coverage-v8": "^4.1.10",
61
- "esbuild": "^0.28.1",
62
- "eslint": "^10.7.0",
63
- "prettier": "^3.9.5",
64
- "tsup": "^8.5.1",
65
- "typescript": "^6.0.3",
66
- "typescript-eslint": "^8.64.0",
67
- "vitest": "^4.1.10"
68
- },
69
- "overrides": {
70
- "esbuild": "^0.28.1"
71
- },
72
- "keywords": [
73
- "webtransport",
74
- "quic",
75
- "http3",
76
- "quiche",
77
- "neon"
78
- ],
79
- "license": "Apache-2.0"
2
+ "name": "rwebtransport",
3
+ "version": "0.2.5",
4
+ "description": "A fully-compatible WebTransport client and server for Node.js, powered by Cloudflare quiche + BoringSSL via neon.",
5
+ "author": "Dacely Cloud",
6
+ "homepage": "https://github.com/dacely-cloud/rwebtransport#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/dacely-cloud/rwebtransport.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/dacely-cloud/rwebtransport/issues"
13
+ },
14
+ "type": "commonjs",
15
+ "main": "./dist/index.js",
16
+ "module": "./dist/index.mjs",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.mjs",
22
+ "require": "./dist/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "prebuilds",
28
+ "scripts",
29
+ "crates",
30
+ "vendor",
31
+ "Cargo.toml",
32
+ "Cargo.lock",
33
+ "README.md",
34
+ "NOTICE"
35
+ ],
36
+ "engines": {
37
+ "node": ">=24 <25 || >=26 <27"
38
+ },
39
+ "scripts": {
40
+ "build": "npm run build:rust && npm run build:ts",
41
+ "build:rust": "node scripts/build.js",
42
+ "build:rust:debug": "node scripts/build.js --debug",
43
+ "build:ts": "node scripts/build-ts.js && tsc -p tsconfig.build.json",
44
+ "build:echo": "cargo build --locked --release -p rwebtransport-echo-server",
45
+ "setup:windows": "powershell -ExecutionPolicy Bypass -File scripts/setup-windows.ps1",
46
+ "setup:unix": "bash scripts/setup-unix.sh",
47
+ "postinstall": "node scripts/postinstall.js",
48
+ "pretest": "npm run build:rust && npm run build:ts && npm run build:echo",
49
+ "test": "vitest run --project node",
50
+ "test:watch": "vitest --project node",
51
+ "typecheck": "tsc --noEmit",
52
+ "lint": "oxlint .",
53
+ "lint:fix": "oxlint . --fix",
54
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
55
+ "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
56
+ "test:browser": "npm run pretest && vitest run --project browser",
57
+ "test:all": "npm run pretest && vitest run",
58
+ "test:coverage": "npm run pretest && vitest run --coverage"
59
+ },
60
+ "devDependencies": {
61
+ "@types/node": "^26.6.6",
62
+ "@vitest/browser-webdriverio": "^5.0.0",
63
+ "@vitest/coverage-v8": "^5.1.1",
64
+ "esbuild": "^0.28.2",
65
+ "oxlint": "^1.94.0",
66
+ "oxlint-tsgolint": "^7.0.2008",
67
+ "prettier": "^3.10.1",
68
+ "typescript": "^7.0.2",
69
+ "vitest": "^5.1.1",
70
+ "webdriverio": "^10.2.0"
71
+ },
72
+ "overrides": {
73
+ "esbuild": "$esbuild",
74
+ "archiver": {
75
+ "readdir-glob": "^4.0.0"
76
+ }
77
+ },
78
+ "keywords": [
79
+ "webtransport",
80
+ "quic",
81
+ "http3",
82
+ "quiche",
83
+ "neon"
84
+ ],
85
+ "license": "Apache-2.0"
80
86
  }
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env bash
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ set -euo pipefail
4
+
5
+ root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
6
+ case "$(uname -m)" in
7
+ x86_64) machine=x86_64; arch=x64 ;;
8
+ aarch64) machine=aarch64; arch=arm64 ;;
9
+ *) echo "Unsupported Linux prebuild architecture" >&2; exit 1 ;;
10
+ esac
11
+
12
+ build_dir=$(mktemp -d)
13
+ trap 'rm -rf -- "$build_dir"' EXIT
14
+ rust_sysroot=$(rustc --print sysroot)
15
+ go_sysroot=$(go env GOROOT)
16
+ runtime=${RWT_CONTAINER_RUNTIME:-docker}
17
+ image="quay.io/pypa/manylinux_2_28_${machine}:latest"
18
+
19
+ "$runtime" run --rm \
20
+ --mount "type=bind,source=$root,target=/repo,readonly" \
21
+ --mount "type=bind,source=$rust_sysroot,target=/rust,readonly" \
22
+ --mount "type=bind,source=$go_sysroot,target=/go,readonly" \
23
+ --mount "type=bind,source=$build_dir,target=/output" \
24
+ --env "CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-8}" \
25
+ --workdir /repo "$image" bash -euc '
26
+ dnf -y -q --setopt=install_weak_deps=False install clang-devel ninja-build
27
+ export PATH="/rust/bin:/go/bin:$PATH"
28
+ export CARGO_TARGET_DIR=/tmp/rwt-target
29
+ cargo build --locked --release -p rwebtransport-native
30
+ install -m 755 "$CARGO_TARGET_DIR/release/librwebtransport_native.so" /output/rwebtransport.node
31
+ '
32
+
33
+ check_versions() {
34
+ local family=$1 maximum=$2 actual
35
+ actual=$(readelf --version-info "$build_dir/rwebtransport.node" |
36
+ awk -v family="$family" '{while (match($0, family "_[0-9]+(\\.[0-9]+)+")) { print substr($0, RSTART, RLENGTH); $0 = substr($0, RSTART + RLENGTH) }}' |
37
+ sort -Vu | tail -1)
38
+ if [[ -n "$actual" && "$(printf '%s\n' "$actual" "${family}_${maximum}" | sort -V | tail -1)" != "${family}_${maximum}" ]]; then
39
+ echo "Linux prebuild requires $actual, above the supported ${family}_${maximum} baseline" >&2
40
+ exit 1
41
+ fi
42
+ }
43
+
44
+ check_versions GLIBC 2.28
45
+ check_versions GLIBCXX 3.4.25
46
+ install -D -m 755 "$build_dir/rwebtransport.node" "$root/prebuilds/linux-$arch/rwebtransport.node"
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ 'use strict';
4
+
5
+ const { rmSync } = require('node:fs');
6
+ const path = require('node:path');
7
+ const { build } = require('esbuild');
8
+
9
+ const root = path.resolve(__dirname, '..');
10
+
11
+ async function main() {
12
+ rmSync(path.join(root, 'dist'), { recursive: true, force: true });
13
+
14
+ for (const format of ['cjs', 'esm']) {
15
+ await build({
16
+ absWorkingDir: root,
17
+ entryPoints: ['src/index.ts'],
18
+ outfile: `dist/index.${format === 'cjs' ? 'js' : 'mjs'}`,
19
+ bundle: true,
20
+ platform: 'node',
21
+ target: 'node24',
22
+ packages: 'external',
23
+ format,
24
+ sourcemap: true,
25
+ // The native addon loader uses import.meta.url in both bundles.
26
+ ...(format === 'cjs'
27
+ ? {
28
+ define: { 'import.meta.url': '__rwebtransportImportMetaUrl' },
29
+ banner: {
30
+ js: "'use strict';\nconst __rwebtransportImportMetaUrl = require('node:url').pathToFileURL(__filename).href;",
31
+ },
32
+ }
33
+ : {}),
34
+ });
35
+ }
36
+ }
37
+
38
+ main().catch((error) => {
39
+ console.error(error);
40
+ process.exitCode = 1;
41
+ });
package/scripts/build.js CHANGED
@@ -35,7 +35,7 @@ function run(cmd, args) {
35
35
  }
36
36
 
37
37
  function main() {
38
- const cargoArgs = ['build', '-p', CRATE];
38
+ const cargoArgs = ['build', '--locked', '-p', CRATE];
39
39
  if (!debug) cargoArgs.push('--release');
40
40
  // Allow an explicit target (used by cross-compiling CI jobs).
41
41
  const target = process.env.CARGO_BUILD_TARGET;
@@ -59,8 +59,15 @@ function main() {
59
59
  const plat = process.env.PREBUILD_PLATFORM || process.platform;
60
60
  const outDir = path.join(root, 'prebuilds', `${plat}-${arch}`);
61
61
  fs.mkdirSync(outDir, { recursive: true });
62
- const out = path.join(outDir, 'rwebtransport.node');
63
- fs.copyFileSync(artifact, out);
62
+ const name = process.argv.includes('--fallback') ? 'rwebtransport-local.node' : 'rwebtransport.node';
63
+ const out = path.join(outDir, name);
64
+ const temporary = `${out}.${process.pid}.tmp`;
65
+ try {
66
+ fs.copyFileSync(artifact, temporary);
67
+ fs.renameSync(temporary, out);
68
+ } finally {
69
+ fs.rmSync(temporary, { force: true });
70
+ }
64
71
  console.error(`copied ${artifact} -> ${out}`);
65
72
  }
66
73
 
@@ -57,6 +57,16 @@ BoringSSL itself is built by `boring-sys` (no in-tree submodule).
57
57
 
58
58
  ## ANTI-PATTERNS
59
59
 
60
+ - Model mutually exclusive lifecycle phases with enums, rather than related
61
+ booleans or overlapping completion predicates. Derive state enums from
62
+ authoritative buffers and acknowledgement data instead of duplicating it.
63
+ Boolean queries remain suitable for independent properties and compatibility
64
+ APIs.
65
+ - Match lifecycle enums exhaustively in transitions and in cleanup or validation
66
+ decisions where a new variant could require a different outcome. Use simple
67
+ predicates for yes/no decisions with an obvious safe default for new variants.
68
+ A single derived helper can centralize a repeated exhaustive decision. Do not
69
+ combine independent flags into an enum; payload wildcards are fine.
60
70
  - **h3::Error != quiche::Error** — don't mix or convert carelessly; they have different variant sets.
61
71
  - **`Error::Done` is a success signal** in many read/write loops — not a failure.
62
72
  - **Don't add new CC impls** outside `recovery/` — two parallel impls (congestion + gcongestion) already exist.