stream: fix ERR_INVALID_STATE when cancelling Readable.toWeb() - #62773
stream: fix ERR_INVALID_STATE when cancelling Readable.toWeb()#62773richardscarrott wants to merge 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.13% +0.01%
==========================================
Files 752 751 -1
Lines 252325 252639 +314
Branches 47456 47546 +90
==========================================
+ Hits 227407 227724 +317
+ Misses 16217 16197 -20
- Partials 8701 8718 +17
π 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. |
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
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. |
Commit Queue failedThe pull request was removed from the Commit Queue and labeled
commit-queue-failed
Full Commit Queue output |
MikeMcC399
left a comment
There was a problem hiding this comment.
See Commit message guidelines according to the Pull requests documentation.
Your commit must contain the Signed-off-by line with your name and email address as an acknowledgement that you agree to the Developer Certificate of Origin.
This rule was introduced after this PR was originally submitted.
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