-
-
Notifications
You must be signed in to change notification settings - Fork 156
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 event doesn't fire on fs.createWriteStream before finish event is fired #189
Comments
Is this happening for 0.10 specifically? Interestingly I bound to "open" to get the fd because I read in the docs that 0.10 doesn't support an But it looks like it actually does: If that is true, perhaps we don't need to listen for "open" at all but can just use |
Looks like it was added back in 2012. |
It's happening on every version, I just had my browser open on that tag. I think the issue has to be something vinyl-fs does with the readable stream but I'm not exactly sure. |
Right. I will have some time this weekend and will look into this (and the mkdirp/chmod thing as well). |
@phated Even though the documentation for 0.10 doesn't mention supporting an ... the commit I linked earlier actually is a part of the 0.10.0 release: So, seems like the 0.10 docs are incomplete in this regard. I tried refactoring the This passes Travis just fine, including 0.10: So far, so good. Unfortunately I can't remove the No time to look into this further just now, but thought I'd share what I found thus far. |
Thinking about this overnight, I realized (and just confirmed) that the problem is https://github.com/gulpjs/vinyl-fs/blob/master/lib/dest/write-contents/write-stream.js#L33-L35 which is being called before anything is written and calling |
The solution seems to be to implement our own FileWriteStream as per https://twitter.com/mafintosh/status/751186046293991424 using https://github.com/mafintosh/flush-write-stream. I'm not really sure how to do this. |
@erikkemperman I think I have something working at https://github.com/gulpjs/vinyl-fs/tree/custom-write-stream - the custom stream implementation will need cleanup, tests and lots of other stuff (I added many TODOs). The test that I was refactoring when I encountered the timeouts is committed on a separate commit in that branch. |
So.. Nothing to do with what I found :-) Looks like you've got this figured out! To think all of these complications are all still due to having to operate on file descriptors, which was only needed because of that frankly terrible quirk with sub-second precision of utimes vs futimes... I will look into the mkdirp/chmod thing tomorrow, and I noticed a minor oddity I might try to address ( |
Having trouble with the file descriptors not being closed on Windows. Still digging into that but everything else looks good for this. |
Tests passing across platforms. Pushed to master! |
Nice! |
All the tests that have streaming content have a
setTimeout(..., 100)
to account for this but that seems wrong. We need to figure out why this is happening.@erikkemperman would you want to dig into this if you have some time? I've been looking at https://github.com/nodejs/node/blob/v0.10.46/lib/fs.js#L1625 but I haven't found anything yet.
The text was updated successfully, but these errors were encountered: