Skip to content
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

Open file with fs.open and use fs.fstat and createWriteStream(null, { fd }) #122

Open
ronag opened this issue Nov 25, 2016 · 1 comment · May be fixed by #125
Open

Open file with fs.open and use fs.fstat and createWriteStream(null, { fd }) #122

ronag opened this issue Nov 25, 2016 · 1 comment · May be fixed by #125

Comments

@ronag
Copy link

ronag commented Nov 25, 2016

Open file with fs.open and use fs.fstat and fs.createReadStream(null, { fd }) otherwise we might have a race where the file at the specified path is replaced in the time between fs.stat and fs.createReadStream and wrong header data is provided.

@jcready
Copy link
Contributor

jcready commented Dec 6, 2016

Have you actually run into this issue? The window of time for something like that to occur must be a few milliseconds at most. Switching to the method you suggest would add significant complexity to error handling because Node will not automatically close the file descriptor if an error occurs and failing to close the file descriptor will eventually lead to an EMFILE: too many open files error being thrown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants