GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||
GeezerVison is showing github.com — stream: keep async context of pipeTo watchers by mcollina · Pull Request #67052 · nodejs/node Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## main #67052 +/- ## ========================================== + Coverage 90.47% 90.65% +0.18% ========================================== Files 791 797 +6 Lines 277245 278279 +1034 Branches 53310 53519 +209 ========================================== + Hits 250834 252283 +1449 + Misses 16811 16371 -440 - Partials 9600 9625 +25
🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Landed in d56c163 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Writable.fromWeb() and Duplex.fromWeb() dispatch writes to the WritableStream directly and complete them through a shared write tracker. A write issued before the WritableStream had started was queued and processed from its start step, so the sink ran in the async context of the code that created the WritableStream, and the tracker invoked the Node.js write callback synchronously from whatever context completed the sink write, so the writes and final() it released ran there too. The promise-based adapter waited for writer.ready and received the result through a reaction, both in the context of the Node.js write. Dispatch writes issued before the start from a writer.ready reaction, failing them if the stream was closed or errored meanwhile, and deliver the write callback in the context of the Node.js write, from a reaction when it completes in another context. Refs: #66906 Refs: #65548 Signed-off-by: Matteo Collina <[email protected]> PR-URL: #67055 Refs: #67052 Refs: #67054 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
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 <[email protected]> PR-URL: #67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
Writable.fromWeb() and Duplex.fromWeb() dispatch writes to the WritableStream directly and complete them through a shared write tracker. A write issued before the WritableStream had started was queued and processed from its start step, so the sink ran in the async context of the code that created the WritableStream, and the tracker invoked the Node.js write callback synchronously from whatever context completed the sink write, so the writes and final() it released ran there too. The promise-based adapter waited for writer.ready and received the result through a reaction, both in the context of the Node.js write. Dispatch writes issued before the start from a writer.ready reaction, failing them if the stream was closed or errored meanwhile, and deliver the write callback in the context of the Node.js write, from a reaction when it completes in another context. Refs: #66906 Refs: #65548 Signed-off-by: Matteo Collina <[email protected]> PR-URL: #67055 Refs: #67052 Refs: #67054 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
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 <[email protected]> PR-URL: #67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
Writable.fromWeb() and Duplex.fromWeb() dispatch writes to the WritableStream directly and complete them through a shared write tracker. A write issued before the WritableStream had started was queued and processed from its start step, so the sink ran in the async context of the code that created the WritableStream, and the tracker invoked the Node.js write callback synchronously from whatever context completed the sink write, so the writes and final() it released ran there too. The promise-based adapter waited for writer.ready and received the result through a reaction, both in the context of the Node.js write. Dispatch writes issued before the start from a writer.ready reaction, failing them if the stream was closed or errored meanwhile, and deliver the write callback in the context of the Node.js write, from a reaction when it completes in another context. Refs: #66906 Refs: #65548 Signed-off-by: Matteo Collina <[email protected]> PR-URL: #67055 Refs: #67052 Refs: #67054 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
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 <[email protected]> PR-URL: #67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
Writable.fromWeb() and Duplex.fromWeb() dispatch writes to the WritableStream directly and complete them through a shared write tracker. A write issued before the WritableStream had started was queued and processed from its start step, so the sink ran in the async context of the code that created the WritableStream, and the tracker invoked the Node.js write callback synchronously from whatever context completed the sink write, so the writes and final() it released ran there too. The promise-based adapter waited for writer.ready and received the result through a reaction, both in the context of the Node.js write. Dispatch writes issued before the start from a writer.ready reaction, failing them if the stream was closed or errored meanwhile, and deliver the write callback in the context of the Node.js write, from a reaction when it completes in another context. Refs: #66906 Refs: #65548 Signed-off-by: Matteo Collina <[email protected]> PR-URL: #67055 Refs: #67052 Refs: #67054 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
The pipeTo() pump re-enters from the destination's ready hook, which writableStreamUpdateBackpressure invokes synchronously, and from the chunk steps of its read request. Both run in the async context of the code that cleared the backpressure or enqueued the chunk, so the source's pull() and the writes issued after a resumption observed that context instead of the one of the pipeTo() call, as they did with the promise-based pump. Capture the async context frame when the pipe starts and run the pump in it. Refs: #66906 Refs: #65138 Signed-off-by: Matteo Collina <[email protected]> PR-URL: #67054 Refs: #67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
The pipeTo() pump re-enters from the destination's ready hook, which writableStreamUpdateBackpressure invokes synchronously, and from the chunk steps of its read request. Both run in the async context of the code that cleared the backpressure or enqueued the chunk, so the source's pull() and the writes issued after a resumption observed that context instead of the one of the pipeTo() call, as they did with the promise-based pump. Capture the async context frame when the pipe starts and run the pump in it. Refs: #66906 Refs: #65138 Signed-off-by: Matteo Collina <[email protected]> PR-URL: #67054 Refs: #67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
The pipeTo() pump re-enters from the destination's ready hook, which writableStreamUpdateBackpressure invokes synchronously, and from the chunk steps of its read request. Both run in the async context of the code that cleared the backpressure or enqueued the chunk, so the source's pull() and the writes issued after a resumption observed that context instead of the one of the pipeTo() call, as they did with the promise-based pump. Capture the async context frame when the pipe starts and run the pump in it. Refs: #66906 Refs: #65138 Signed-off-by: Matteo Collina <[email protected]> PR-URL: #67054 Refs: #67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
The pipeTo() pump re-enters from the destination's ready hook, which writableStreamUpdateBackpressure invokes synchronously, and from the chunk steps of its read request. Both run in the async context of the code that cleared the backpressure or enqueued the chunk, so the source's pull() and the writes issued after a resumption observed that context instead of the one of the pipeTo() call, as they did with the promise-based pump. Capture the async context frame when the pipe starts and run the pump in it. Refs: #66906 Refs: #65138 Signed-off-by: Matteo Collina <[email protected]> PR-URL: #67054 Refs: #67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
The pipeTo() pump re-enters from the destination's ready hook, which writableStreamUpdateBackpressure invokes synchronously, and from the chunk steps of its read request. Both run in the async context of the code that cleared the backpressure or enqueued the chunk, so the source's pull() and the writes issued after a resumption observed that context instead of the one of the pipeTo() call, as they did with the promise-based pump. Capture the async context frame when the pipe starts and run the pump in it. Refs: nodejs#66906 Refs: nodejs#65138 Signed-off-by: Matteo Collina <[email protected]> PR-URL: nodejs#67054 Refs: nodejs#67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
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: nodejs#66906 Refs: nodejs#66424 Signed-off-by: Matteo Collina <[email protected]> PR-URL: nodejs#67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
Writable.fromWeb() and Duplex.fromWeb() dispatch writes to the WritableStream directly and complete them through a shared write tracker. A write issued before the WritableStream had started was queued and processed from its start step, so the sink ran in the async context of the code that created the WritableStream, and the tracker invoked the Node.js write callback synchronously from whatever context completed the sink write, so the writes and final() it released ran there too. The promise-based adapter waited for writer.ready and received the result through a reaction, both in the context of the Node.js write. Dispatch writes issued before the start from a writer.ready reaction, failing them if the stream was closed or errored meanwhile, and deliver the write callback in the context of the Node.js write, from a reaction when it completes in another context. Refs: nodejs#66906 Refs: nodejs#65548 Signed-off-by: Matteo Collina <[email protected]> PR-URL: nodejs#67055 Refs: nodejs#67052 Refs: nodejs#67054 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
The pipeTo() pump re-enters from the destination's ready hook, which writableStreamUpdateBackpressure invokes synchronously, and from the chunk steps of its read request. Both run in the async context of the code that cleared the backpressure or enqueued the chunk, so the source's pull() and the writes issued after a resumption observed that context instead of the one of the pipeTo() call, as they did with the promise-based pump. Capture the async context frame when the pipe starts and run the pump in it. Refs: nodejs#66906 Refs: nodejs#65138 Signed-off-by: Matteo Collina <[email protected]> PR-URL: nodejs#67054 Refs: nodejs#67052 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Paolo Insogna <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.