-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
pipeline causes script to silently crash #38539
Comments
Pipeline internally calls In general, pipeline states that it closes all streams given to it (if they are not closed by themselves), and the documentation officially discourages reusing streams that have been used in pipeline. https://nodejs.org/api/stream.html#stream_stream_pipeline_streams_callback |
I understand now pipeline ending the stream even though it's state is closed:false,destroyed:false,ended:true,finished:true,writing:false Is a "swallowed error" where a script will abruptly end no errors? In my script an error will trigger if output.write() is called after the first pipeline, the error is about writing to a stream already ended. However pipeline by design will "swallow the error" and silently end the script? |
|
So the above script when the 2 lines are un-commented you get output in your console? |
|
Previous versions of node the second pipeline call fails as expected node versions 14 and up the above code the error gets swallowed and script exits abruptly at second pipeline call interesting that node version 13 the error changes from write stream end to bad file descriptor EXAMPLE USING NVM:
|
Since Node 14, destroyed streams no longer emit errors #29197, that's why you've seen errors until Node 13. What you're seeing is a bug with pipeline, and is essentially a duplicate of #36674 and will be fixed when #36791 is merged (hopefully soon). Regarding Node shutting down - I retract my statement regarding closed FDs, it was totally wrong. It looks like there really is no crash. The event loop is totally empty and Node just exits. Something similar to the following: async function func() {
const promise = new Promise(()=>{});
await promise;
console.log('bye');
}
func(); |
Should be fixed in master 🎉 |
I arrive here after the battle. I encountered a very similar issue early 2021. I was refactoring some code today, I just found this problem again. Following @benjamingr last comment, I upgraded to node 18.2 to run the code and I can still trigger the Node exit. Any chance the bug has not been fixed? |
Version: 16
Platform: Linux webdev-g7 5.4.0-72-generic #80-Ubuntu SMP Mon Apr 12 17:35:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
How often does it reproduce? Is there a required condition?
Everytime script is run
What is the expected behavior?
I see "done." it appended the two files.
What do you see instead?
Nothing it silently crashes
Additional information
Here is a workaround with notes https://gist.github.com/webdevlocalhost/32822034a003d93f0452dff4d48e73c8
The text was updated successfully, but these errors were encountered: