Commit 7ce5532
committed
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: #621991 parent bf1aebc commit 7ce5532
File tree
2 files changed
+59
-6
lines changed- lib/internal/webstreams
- test/parallel
2 files changed
+59
-6
lines changed| 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 | | |
| |||
Lines 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