Repository navigation
Commit caa48a3
stream: keep async context of pipeTo watchers
The ClosedPromiseHook records that pipeTo() and tee() install as the
[[closedPromise]] of their reader and writer enqueued the watcher from
whoever settled the record. The source-closed, source-errored and
dest-errored steps of pipeTo() therefore ran in the async context of
the code that closed or errored the stream, so the destination's
close() and abort() and the source's cancel() observed the wrong
AsyncLocalStorage store. Capture the async context frame when the
hook is installed and register the reaction in it, as the spec's
promise reaction would.
Add a test that records the context each underlying source, sink and
transformer callback observes across readable, writable, transform,
pipe and tee scenarios, so scheduling shortcuts that drop the context
are caught.
Refs: #66906
Refs: #66424
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #67052
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>1 parent bf7bef4 commit caa48a3
2 files changed
Lines changed: 621 additions & 2 deletions
File tree
- lib/internal/webstreams
- test/parallel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
1547 | 1549 | | |
1548 | 1550 | | |
1549 | 1551 | | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
1550 | 1555 | | |
1551 | 1556 | | |
1552 | 1557 | | |
1553 | 1558 | | |
1554 | 1559 | | |
| 1560 | + | |
1555 | 1561 | | |
1556 | 1562 | | |
1557 | 1563 | | |
1558 | | - | |
1559 | | - | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
1560 | 1569 | | |
1561 | 1570 | | |
1562 | 1571 | | |
1563 | 1572 | | |
| 1573 | + | |
1564 | 1574 | | |
| 1575 | + | |
1565 | 1576 | | |
1566 | 1577 | | |
1567 | 1578 | | |
| |||
0 commit comments