-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
createWriteStream; close doesn't finish writing all data to file #5631
Comments
Here is a working example. In order to have a guarantee that 'use strict'
const fs = require('fs')
const stream = fs.createWriteStream('out.txt')
stream.write('line one', () => {
stream.write('line two', () => {
stream.close()
})
}) |
Okay I started to dig into the code, and added some console.log( stream ); after the writes.... there's a 'pendingcb' which goes up, and things start to get buffered... so I supposed maybe if there wasn't a callback it would fail. It will take some time to restructure the code to fit HAVING to use the callbacks. but even in a more complex case where I continue on to do other work with other files for a long amount of time the output still doesn't go... so the pending writes apparently never get called without having a callback of some sort... |
@d3x0r , maybe you are looking for Note that |
I had added
but that made no difference. |
This works as expected. |
confirmed; replacing close with end lets it work :) |
close() is no longer a method on the writable instance, use end() instead |
is there no way to use EDIT: Solution is here: nodejs/help#1641 (comment) credit to @provCristianMaluenda:
|
Windows 7/10,
node 5.6.0, and latest builds...
This seems like something fairly critical...
results in a file that only has 'line one' in it.
it can be several lines... I'm often missing 5 lines in this one file... but basically every file never writes all information to the file.
this might be similar to #2314
The text was updated successfully, but these errors were encountered: