Commit 3ed7835
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 c400d46 commit 3ed7835Copy full SHA for 3ed7835
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 |
|---|---|---|
| ||
313 | 313 | |
314 | 314 | |
315 | 315 | |
316 | | - |
317 | 316 | |
318 | | - |
| 317 | + |
319 | 318 | |
320 | 319 | |
321 | 320 | |
| ||
333 | 332 | |
334 | 333 | |
335 | 334 | |
336 | | - |
| 335 | + |
337 | 336 | |
338 | 337 | |
339 | 338 | |
| ||
775 | 774 | |
776 | 775 | |
777 | 776 | |
778 | | - |
779 | 777 | |
780 | | - |
| 778 | + |
781 | 779 | |
782 | 780 | |
783 | 781 | |
| ||
795 | 793 | |
796 | 794 | |
797 | 795 | |
798 | | - |
| 796 | + |
799 | 797 | |
800 | 798 | |
801 | 799 | |
|
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