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 89.69% 89.69%
=======================================
Files 706 706
Lines 218127 218144 +17
Branches 41734 41743 +9
=======================================
+ Hits 195651 195669 +18
+ Misses 14400 14396 -4
- Partials 8076 8079 +3
🚀 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. |
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