-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Closing filehandle after being used in a stream exits node without error message #48466
Comments
The issue is we " node/lib/internal/fs/streams.js Line 139 in 9f19253
And we are never " node/lib/internal/fs/streams.js Line 89 in 9f19253
In your case, I think you expect |
Sounds reasonable. Unfortunately, I'm not fluent in the node base classes codebase... |
As far as I read the code, end() basically finishes a stream. So should the unref() happen when we receive the "finish" event? Probably not before, because data could still to be written... |
Is there a workaround for this? I'm trying to do a similar pattern here so that I can ensure With this added in node21 (#49886), I see a path for safe fs stream IO, but I don't really understand how reliable FS stream writes are possible in node20 with this unresolved bug. |
Version
20.3.0
Platform
Linux zuse1.efi.fh-nuernberg.de 5.4.17-2136.319.1.4.el8uek.x86_64 #2 SMP Mon Jun 5 13:39:13 PDT 2023 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
streams
What steps will reproduce the bug?
I use a stream for writing into a filehandle (of a regular file). After closing the stream (not the filehandle!) I write to other positions in the file.
When I now close the file, node simply exists with return code 0. Following code is NOT executed.
How often does it reproduce? Is there a required condition?
Reproduces always. Tried on v16, v18, v20.
What is the expected behavior? Why is that the expected behavior?
Output:
Content of /tmp/ttt.txt:
Works correctly with fs.closeSync (fh.fd); enabled instead of await fh.close();
Also works as expected, if the whole stream related block is commented out (contents of ttt.txt will differ).
What do you see instead?
Output:
Content of /tmp/ttt.txt:
Additional information
No response
The text was updated successfully, but these errors were encountered: