New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: correctly handle nexttick scheduling in stream reads #24022
fix: correctly handle nexttick scheduling in stream reads #24022
Conversation
Just to add a little context. nextTicks in Node er technically afterTicks as they run in the same event tick as the last thing (legacy naming). In practice this bug manifest itself almost immediately on any stream returned that’s the last stream in a pipeline as they will have lots of these “read returns null but data is added later in the tick” events |
added workaround for electron/electron#24022 and electron/electron#24014
NodeStreamLoader needs a rewrite. It's extremely subtle and full of incorrect behaviors like this 😞 Preferably, a rewrite would have the C++ side expose a much simpler "raw" API than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node.js streaming is so hard 😞 , thanks for fixing this!
Release Notes Persisted
|
I was unable to backport this PR to "8-x-y" cleanly; |
I have automatically backported this PR to "10-x-y", please check out #24081 |
I have automatically backported this PR to "9-x-y", please check out #24082 |
Description of Change
We discovered some cases where protocol streaming responses would stall before completing. We isolated the issue to the case where a stream's read handler scheduled a
push()
usingnextTick()
, which (according to @mafintosh, who I trust to know about this sort of thing) will get scheduled to run prior to control being returned to C++. This means the call into js'read()
will return nothing, but the'readable'
event will get missed.We were able to fix this by flagging when that occurs and automatically retrying the read.
Checklist
npm test
passesRelease Notes
Notes: Fix an issue which would cause streaming protocol responses to stall in some cases