-
Notifications
You must be signed in to change notification settings - Fork 93
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
[WIP] fix(unlink): unlink file even the file descriptor has been closed already #47
Conversation
…st unsafe==false failed to remove test data
There are other issues in the test environment which need to be addressed. |
@raszi with all of the current patches in place, including this one, test cases will no longer leave any temporary files a/o directories, at least this was the case when I last ran npm test on node-tmp. |
@raszi Yes, you are correct in that other error codes might be returned. Excerpt from the man page for close():
And this why we would raise the exception again in case of either EINTR or EIO or anything other that is currently not on the menu. However, and since close() is the final operation on that file, we should try to unlink the file in the finally block and hope that this will succeed, otherwise an exception would be raised there that will then be passed to the user. |
Looking at both #58 and #52 it seems that the original try/catch around the fs.closeSync was correct, see afe2af9#diff-4f99eaef47493ba13b06879592d2a1c4R199 It must, however, be extended to also test for ENOENT in case that the file was never created. |
@raszi Please have a look at the mentioned issues and this pending PR. Come on, you get a whopping 200k downloads per day on NPM 💃 |
I haven't tested this change, but I have found that running the test suite on master leaves files such as:
Running the suite repeated can result in bogus suite failures because the tests are unable to obtain a unique file name after the maximum number of tries. |
Most of this has already been included in master and it no longer shows any left over files when running tests, closing. |
Fixes #31
Fixes #52