Commit 57e59ea
stream: fix writev unhandled rejection in fromWeb
When using Duplex.fromWeb() or Writable.fromWeb() with cork()/uncork(),
writes are batched into _writev(). If destroy() is called in the same
microtask, the underlying WritableStream writer gets aborted, causing
SafePromiseAll() to reject with a non-array value (e.g. an AbortError).
The done() callback in _writev() of both fromWeb adapter functions
unconditionally called error.filter(), assuming the value was always an
array. This caused a TypeError that became an unhandled rejection,
crashing the process.
Fix by separating the resolve and reject handlers of SafePromiseAll:
use () => done() on the resolve path (all writes succeeded, no error)
and done on the reject path (error passed directly to callback).
Fixes: #62199
Signed-off-by: sangwook <rewq5991@gmail.com>
PR-URL: #62297
Reviewed-By: René <contact.9a5d6388@renegade334.me.uk>1 parent d1c517f commit 57e59eaCopy full SHA for 57e59ea
2 files changed
+59-6Lines changed: 59 additions & 6 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- lib/internal/webstreams
- test/parallel
Expand file treeCollapse file tree
Open diff view settings
Collapse file
lib/internal/webstreams/adapters.js
Copy file name to clipboardExpand all lines: lib/internal/webstreams/adapters.js+4-6Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
314 | 314 | |
315 | 315 | |
316 | 316 | |
317 | | - |
318 | 317 | |
319 | | - |
| 318 | + |
320 | 319 | |
321 | 320 | |
322 | 321 | |
| ||
334 | 333 | |
335 | 334 | |
336 | 335 | |
337 | | - |
| 336 | + |
338 | 337 | |
339 | 338 | |
340 | 339 | |
| ||
787 | 786 | |
788 | 787 | |
789 | 788 | |
790 | | - |
791 | 789 | |
792 | | - |
| 790 | + |
793 | 791 | |
794 | 792 | |
795 | 793 | |
| ||
807 | 805 | |
808 | 806 | |
809 | 807 | |
810 | | - |
| 808 | + |
811 | 809 | |
812 | 810 | |
813 | 811 | |
|
Collapse file
test/parallel/test-webstreams-duplex-fromweb-writev-unhandled-rejection.js
Copy file name to clipboard+55Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 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 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
0 commit comments