Repository navigation
Commit 65fd468
committed
fix(node): make toWebReadableStream cancel-safe on every Node release
The Readable.toWeb + TransformStream approach only shielded the adapter's
controller on some Node releases: on Node 24 a chunk arriving after cancel
still hit the closed controller and crashed the process with an uncaught
ERR_INVALID_STATE, even for plain Readable sources.
Hand-roll the adapter instead of wrapping Readable.toWeb: chunks are only
enqueued inside pull(), which never runs after cancel, so the crash is
impossible by construction regardless of Node's adapter internals. Cancel
destroys the source, except http1 server requests — they share their
socket with the response, so they are abandoned (stalled by backpressure,
reclaimed on connection teardown) to keep in-flight responses deliverable.
All package and e2e suites pass on Node 22, 24, and 26.1 parent eca913f commit 65fd468
1 file changed
Lines changed: 42 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | | - | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
7 | 8 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
19 | 49 | | |
20 | | - | |
| 50 | + | |
21 | 51 | | |
22 | 52 | | |
23 | 53 | | |
| |||
0 commit comments