Comments (7)
Optimally it'd clean up any temp files on exit.
Optimally, yes, but cleanup on exit in Node is not really very optimal (because you have no guarantees that anything async will complete before the process shuts down). We could enqueue files into a list and then fs.unlinkSync()
them on exit (npm 2 does something similar for rollback), but that feels a little high-level for what is right now a package focused on doing one relatively simple thing.
Also, are there any reasons to not write the temp files to
os.tmpdir()
?
VERY YES. The atomicity of the operation depends on fs.rename()
being atomic, and you can't rename across filesystem boundaries (since all you're doing is changing what name is mapped to a given inode).
from fs-write-stream-atomic.
I guess we could do it manually in our package by removing this.__atomicTmp
on process.exit
or process.SIGINT
.
from fs-write-stream-atomic.
It's tricky, because I've seen exit handlers fail to fire once there are more than a couple process.on('exit')
listeners in some versions of Node.
from fs-write-stream-atomic.
because you have no guarantees that anything async will complete before the process shuts down
Maybe someday (hopefully I'm still alive :p): http://nodejs.org/docs/v0.11.13/api/process.html#process_event_beforeexit
It's tricky, because I've seen exit handlers fail to fire once there are more than a couple process.on('exit') listeners in some versions of Node.
Still better than nothing though.
from fs-write-stream-atomic.
Yeah, beforeExit
is a possibility, but it'd still be best-effort, because fs.writeStreamAtomic
's primary consumer (not naming any names cough) is still going to need to support 0.10 after the release of 0.12, and realistically, people will complain if it doesn't work with 0.8 for some time after 0.12's release as well. That said, if somebody put together a patch adding this in an opt-in, backwards-compatible way, we'd take it.
from fs-write-stream-atomic.
Failing to remove temporary files isn't a disaster, it's merely the current behaviour.
Adding best-effort tempfile removal shouldn't be blocked by imperfection, imo.
from fs-write-stream-atomic.
It has been about a year, with a few major versions of Node with beforeExit
. Any updated thoughts on this?
from fs-write-stream-atomic.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fs-write-stream-atomic.