stream: fix ERR_INVALID_STATE when cancelling Readable.toWeb() - #62773
nodejs-github-bot merged 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62773 +/- ##
==========================================
+ Coverage 90.12% 90.17% +0.05%
==========================================
Files 752 771 +19
Lines 252325 264910 +12585
Branches 47456 50310 +2854
==========================================
+ Hits 227407 238894 +11487
- Misses 16217 16981 +764
- Partials 8701 9035 +334
🚀 New features to boost your workflow:
|
|
Thank you for your contribution @richardscarrott! Could you please fix the linting errors? |
|
Howdy folks! I think we're running into this as well — @richardscarrott if you don't have time to take this over the finish line, happy to take it over and fix the linting errors! |
|
@smoores-dev @efekrskl soz, forgot about this. I have some time tomorrow to fix this up. |
96e546b to
93b1db6
Compare
|
Rebased onto main and fixed the lint error. Worth flagging for re-review: #62394 rewrote Note this is the @meixg your approval predates the rebase, so this likely needs another look. |
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
When a web ReadableStream returned by Readable.toWeb() is cancelled while the underlying Readable is actively producing data, a pending onData callback can still fire after the controller has been closed and attempt to enqueue a chunk, throwing ERR_INVALID_STATE. Check wasCanceled in the onData handler and return early to avoid calling controller.enqueue() on a closed controller. Refs: nodejs#54205 Signed-off-by: Richard Scarrott <riscarrott@googlemail.com>
93b1db6 to
c0fe52d
Compare
|
Added the missing Could a collaborator start a fresh CI run and re-add the |
Thanks for fixing the trailer!
@panva is re-running the GitHub Actions CI. I have put back the
author ready
It's going to need another Jenkins CI triggered, however there is currently some work being done to fix a flaky test, so I'll let @panva continue looking after your PR. |
This comment has been minimized.
This comment has been minimized.
|
Landed in 1278496 |
When a web ReadableStream returned by Readable.toWeb() is cancelled while the underlying Readable is actively producing data, a pending onData callback can still fire after the controller has been closed and attempt to enqueue a chunk, throwing ERR_INVALID_STATE. Check wasCanceled in the onData handler and return early to avoid calling controller.enqueue() on a closed controller. Refs: #54205 Signed-off-by: Richard Scarrott <riscarrott@googlemail.com> PR-URL: #62773 Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
When a web ReadableStream returned by Readable.toWeb() is cancelled while the underlying Readable is actively producing data, a pending onData callback can still fire after the controller has been closed and attempt to enqueue a chunk, throwing ERR_INVALID_STATE. Check wasCanceled in the onData handler and return early to avoid calling controller.enqueue() on a closed controller. Refs: #54205 Signed-off-by: Richard Scarrott <riscarrott@googlemail.com> PR-URL: #62773 Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
…100) The Node 26 CI job is green again. Node 26.10 fixed the uncatchable `ERR_INVALID_STATE` crash when a `Readable.toWeb` stream is cancelled mid-upload (nodejs/node#62773). The two tests that expected the plain adapter to crash started failing, so they are removed. `toWebReadableStream` keeps working as before, and its doc comment now says to switch back to `Readable.toWeb` once every supported Node release has the fix. ## Fixes - `test_node_matrix (26)` no longer fails with `expected 0 to be greater than 0` on Node 26.10. - The tests showing `toWebReadableStream` survives aborted HTTP/1 and HTTP/2 uploads are unchanged and still run on every Node version. ## Context - The removed tests came from #76. They were meant to fail once Node shipped a fix, and Node 26.10 is that fix. - The workaround stays: Node 22.23 and 24.21 still crash when checked locally, and CI also tests Node 20. ## Testing - `packages/node/src/utils.test.ts` passes on Node 22.23, 24.21, 26.7 and 26.10. - Lint and type check pass.
When a web ReadableStream returned by Readable.toWeb() is cancelled while the underlying Readable is actively producing data, a pending onData callback can still fire after the controller has been closed and attempt to enqueue a chunk, throwing ERR_INVALID_STATE. Check wasCanceled in the onData handler and return early to avoid calling controller.enqueue() on a closed controller. Refs: #54205 Signed-off-by: Richard Scarrott <riscarrott@googlemail.com> PR-URL: #62773 Reviewed-By: Xuguang Mei <meixuguang@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
When a web ReadableStream returned by Readable.toWeb() is cancelled while the underlying Readable is actively producing data, a pending onData callback can still fire after the controller has been closed and attempt to enqueue a chunk, throwing ERR_INVALID_STATE.
Check wasCanceled in the onData handler and return early to avoid calling controller.enqueue() on a closed controller.
Refs: #54205