Repository navigation
Commit a546fba
committed
stream: fix pipeTo assert when writer is released during microtask
The deferred write introduced by commit 65aa8f6 ("stream: fix
pipeTo to defer writes per WHATWG spec") wraps the write operation in
queueMicrotask(). A race condition exists where the pipe can shutdown
and release the writer between when [kChunk] schedules the microtask
and when it executes, causing an ERR_INTERNAL_ASSERTION because
writer[[stream]] is undefined.
Fix by moving the shuttingDown flag into the shared pipe state object
so that PipeToReadableStreamReadRequest can check it. The microtask
now skips the write if the pipe has already begun shutting down.
This aligns with the WHATWG Streams spec step 15 which states:
"if shuttingDown becomes true, the user agent must not initiate
further reads from reader, and must only perform writes of
already-read chunks".
Fixes: #63732
Signed-off-by: Qingyu Wang <wangqingyu.c0l1n@bytedance.com>1 parent b345a17 commit a546fba
2 files changed
Lines changed: 47 additions & 9 deletions
File tree
- lib/internal/webstreams
- test/parallel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1424 | 1424 | | |
1425 | 1425 | | |
1426 | 1426 | | |
1427 | | - | |
1428 | | - | |
1429 | 1427 | | |
1430 | 1428 | | |
1431 | 1429 | | |
| |||
1438 | 1436 | | |
1439 | 1437 | | |
1440 | 1438 | | |
| 1439 | + | |
1441 | 1440 | | |
1442 | 1441 | | |
1443 | 1442 | | |
| |||
1462 | 1461 | | |
1463 | 1462 | | |
1464 | 1463 | | |
1465 | | - | |
1466 | | - | |
| 1464 | + | |
| 1465 | + | |
1467 | 1466 | | |
1468 | 1467 | | |
1469 | 1468 | | |
| |||
1483 | 1482 | | |
1484 | 1483 | | |
1485 | 1484 | | |
1486 | | - | |
1487 | | - | |
| 1485 | + | |
| 1486 | + | |
1488 | 1487 | | |
1489 | 1488 | | |
1490 | 1489 | | |
| |||
1546 | 1545 | | |
1547 | 1546 | | |
1548 | 1547 | | |
1549 | | - | |
| 1548 | + | |
1550 | 1549 | | |
1551 | 1550 | | |
1552 | 1551 | | |
1553 | | - | |
| 1552 | + | |
1554 | 1553 | | |
1555 | 1554 | | |
1556 | 1555 | | |
| |||
1563 | 1562 | | |
1564 | 1563 | | |
1565 | 1564 | | |
1566 | | - | |
| 1565 | + | |
1567 | 1566 | | |
1568 | 1567 | | |
1569 | 1568 | | |
| |||
1678 | 1677 | | |
1679 | 1678 | | |
1680 | 1679 | | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
1681 | 1684 | | |
1682 | 1685 | | |
1683 | 1686 | | |
| |||
Lines changed: 35 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 | + | |
0 commit comments