Commit 07360bc
easonysliu
stream: fix TypeError in writev when writer.ready rejects
The `done` callback in the `writev` handlers of both
`newStreamWritableFromWritableStream` and
`newStreamDuplexFromReadableWritablePair` unconditionally called
`error.filter()`, assuming `error` is always an array from
`SafePromiseAll`. However, `done` is also used as the rejection
handler for `writer.ready`, which passes a single error value,
not an array. This caused a `TypeError: error.filter is not a
function` which became an unhandled rejection, crashing the
process.
Fix by checking whether `error` is an array before filtering,
and also use `ArrayIsArray`/`ArrayPrototypeFilter` from primordials
to follow Node.js internal conventions.
Fixes: #621991 parent a62f641 commit 07360bc
File tree
2 files changed
+73
-4
lines changed- lib/internal/webstreams
- test/parallel
2 files changed
+73
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
316 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
317 | 324 | | |
318 | | - | |
| 325 | + | |
319 | 326 | | |
320 | 327 | | |
321 | 328 | | |
| |||
775 | 782 | | |
776 | 783 | | |
777 | 784 | | |
778 | | - | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
779 | 792 | | |
780 | | - | |
| 793 | + | |
781 | 794 | | |
782 | 795 | | |
783 | 796 | | |
| |||
Lines changed: 56 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 | + | |
| 56 | + | |
0 commit comments