-
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
Asynchronous Cleanup Callback #155
Asynchronous Cleanup Callback #155
Comments
@freitagbr would you require a callback for notification on when tmp is done removing the temporary objects? Oh, wait, there is already the next callback that can be passed to the cleanupCallback. So you are free to use that if you like, as it is optional. |
@freitagbr the problem, though, is that even on process.nextTick, the operation will still be blocking. How do you envision tmp to be removing such large directories? And is it even an issue, considering that tmp will be removing these files on process exit only or whenever the cleanup callback is being called. What is your actual use case here? Why do you keep that many temporary files in a single location so that it will stall the operation of your application? |
My use case is that I'm creating temp directories as a sandbox to unzip .zip files (potentially very large, say 100GB+), manipulate the contained files, repackage them, and then send them off somewhere else. Sure, if the cleanup callback is deferred with |
This is even more involved as we also install a process.exit listener to handle graceful cleanups whenever a process exists or gets terminated. Inside these handlers we cannot run any asynchronous code. Yet another problem to be solved, yeah. |
I see that |
@freitagbr thank you very much for your invaluable input. in #161 I do exactly what you proposed and it works like a charm. However, we still need to reduce the extra amount of code and by that I mean we have to just eliminate it by using rimraf. Not for files, though, as these still need to be closed in case of an open file descriptor. |
Operating System
NodeJS Version
Tmp Version
v0.0.33
Expected Behavior
The
cleanup
callback provided bytmp.dir
andtmp.dirSync
removes the temp directory asynchronously.Experienced Behavior
The
cleanup
callback provided bytmp.dir
andtmp.dirSync
removes the temp directory synchronously. It would be awesome to have an option to make thecleanup
callback asynchronous, so that removing directories with a lot of contents doesn't block.The text was updated successfully, but these errors were encountered: