-
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 pre-aborted writeFile AbortSignal file leak #37393
fs: fix pre-aborted writeFile AbortSignal file leak #37393
Conversation
Could you add a test? Also, do you know if it also happens on |
Sure
It doesn't, however I could add the "optimization" that I added here (the file still opens, even if the signal is already aborted). |
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.
good catch
(Please add a test) |
6e0162c
to
dd95fb7
Compare
@aduh95 @benjamingr I've added tests. I'm not 100% happy about them, as it's hard for me to know if they'll work consistently on other platforms... 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 (The tests are essentially copy/pasted from my other fs PR, just changed for the promisified version). EDIT: clearly doesn't work... I'll try to find another solution. |
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.
If making a robust test is too tricky, I think we should land this without one.
dd95fb7
to
9778ea3
Compare
removed test changes |
9778ea3
to
758d27a
Compare
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.
lgtm without the test due to the circumstances.
758d27a
to
edd2871
Compare
f828fa8
to
76892da
Compare
76892da
to
936160f
Compare
f14faab
to
a95971f
Compare
a95971f
to
6425b00
Compare
6425b00
to
39e50ac
Compare
Fix an issue in writeFile where a file is opened, and not closed if the abort signal is aborted after the file was opened but before writing began. PR-URL: nodejs#37393 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
39e50ac
to
c4180b7
Compare
Landed in c4180b7 |
Fix an issue in writeFile where a file is opened, and not closed if the abort signal is aborted after the file was opened but before writing began. PR-URL: #37393 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Fix an issue in writeFile where a file is opened, and not closed if the abort signal is aborted after the file was opened but before writing began. PR-URL: nodejs#37393 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Fix an issue in writeFile where a file is opened, and not closed if the abort signal is aborted after the file was opened but before writing began. PR-URL: nodejs#37393 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Fix an issue in writeFile where a file is opened, and not closed if the abort signal is aborted after the file was opened but before writing began. PR-URL: nodejs#37393 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Fix an issue in writeFile where a file is opened, and not closed if the abort signal is aborted after the file was opened but before writing began. PR-URL: #37393 Backport-PR-URL: #38386 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This fixes an issue in
promises.writeFile
where a file is opened, and not closed if the abort signal is aborted before/during the file was opened.A minor thing is that
fd.close
can still throw, I'm not sure if it's an issue or not.In addition I also added validation for the AbortSignal, and a check where if the signal was already aborted, the file won't be opened at all.
make -j4 test
(UNIX), orvcbuild test
(Windows) passes