| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
So that's the same bug as in #37393, except in the callback version, correct? It'd be nice to have a test also. |
Sorry, something went wrong.
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). |
Sorry, something went wrong.
|
Yeah, indeed, writeAll is always called with a length of data.byteLength to write in one go; I guess this might happen only if there are some OS or hardware limitations in place. Maybe that's something that can be set up a CI? //cc @nodejs/fs |
Sorry, something went wrong.
@aduh95 going over things again, you're right that another case that had a problem before was if the controller was aborted between the file.open and writeAll - which was also fixed by this PR. This can be seen by executing test-fs-write-file and adding setTimeout(()=>fs.readdir('/dev/fd',(err,list)=>console.log(list.length)),1000) it's 28 after my PR, and 30 if I revert it. Removing the last two tests in the file brings it to 28/28 (as they both abort the controller before the internal open finishes). 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 _getActiveHandles and _getActiveRequests which I thought might work, but they didn't. |
Sorry, something went wrong.
Sorry, something went wrong.
Sorry, something went wrong.
|
@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. |
Sorry, something went wrong.
|
Reverted tests. |
Sorry, something went wrong.
Sorry, something went wrong.
|
Is there anything else that I need to do here? |
Sorry, something went wrong.
Sorry, something went wrong.
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>
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>
| Back | FazBrowse Home | New Git URL |
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)