-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
fs: fix writeFile AbortSignal does not close file #37402
Conversation
So that's the same bug as in #37393, except in the callback version, correct? It'd be nice to have a test also. |
Not exactly the same bug. In the promsified version non-"pre-aborted" are fine (the file closes correctly in the promisifed version if the signal is aborted after the file is opened, and writing has begun). The issue here is when the write doesn't write everything in one-go, I'm not sure how to simulate it (I tried and couldn't get it to work consistently even with large buffers). |
Yeah, indeed, //cc @nodejs/fs |
@aduh95 going over things again, you're right that another case that had a problem before was if the controller was aborted between the However, I'm just not sure how to get all of the file handles in a cross-platform and consistent way through node, I tried using |
6e6229e
to
a7f00e3
Compare
@aduh95 I've added tests. I'm not 100% happy about them, as it's hard for me to know if they'll work consistently... However, on my machine they do work consistently on this branch, and fail consistently on master. I'd be happy to improve them if you have any pointers. EDIT: clearly doesn't work... I'll try to find another solution. |
Reverted tests. |
b2faef5
to
1cc6a55
Compare
1e85f15
to
cb2f35a
Compare
Is there anything else that I need to do here? |
Fix an issue where the writeFile does not close the file when the signal is aborted. PR-URL: nodejs#37402 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
cb2f35a
to
503d6cc
Compare
Landed in 503d6cc |
Fix an issue where the writeFile does not close the file when the signal is aborted. PR-URL: #37402 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Fix an issue where the writeFile does not close the file when the signal is aborted. PR-URL: #37402 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This PR fixes an issue where the callback-style writeFile does not close the fd when the AbortSignal is aborted
(readFile handles this correctly).
I've also "optimized" the read-path to not open the file if the signal is aborted before the file is even opened.
(this PR is different than my other PR, which fixed an issue in promisified writeFile)
make -j4 test
(UNIX), orvcbuild test
(Windows) passes