-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
fs.createWriteStream: add util.promisify support. #16989
Comments
I don't think this makes sense since I'd expect If anything, you can propose promisifying |
Thanks a lot for bringing this up by the way. |
@benjamingr I'm not sure I understand what you mean by promisifying Also my idea behind promisifying createWriteStream is that the returned stream is the "ready" on return. Maybe this is a special case for Looking at the |
@mscdex Should I post a separate issue for the bug part of this? Using the promisified version of a function that doesn't support promisify should throw a JS error, not silently exit node. |
according to documentation util.promisify
|
That's fine I've moved on, I used fs.open instead. But node should not crash if someone tries promisifying fs.createWriteStream. |
@coreyfarrell we've updated the docs on what I'm going to close this since you're no longer pursuing, if you feel strongly against this let me know and I'll reopen. Thanks for taking the time and making the effort by the way. Any feedback about how we can make a better Node promises story is very appreciated. |
@benjamingr I do still think it is a bug that my example code exits silently. I no longer feel that it's worth while for the stream methods to work with |
Just a heads up that I also expected promisify to work on writeable streams. Exiting silently was a bit confusing and unexpected as a module user. |
This causes 'output.log' to be created but empty, node.js exits silently.
I've created a "polyfill" which seems to work and do what I would expect:
I'm not yet prepared to submit a pull request for this (it will be my first to node). I have code in lib/fs.js that I think correctly uses the internal version of the promises, I haven't had a chance to build. I'm not sure what automatic tests would be needed for this feature, I've only tested this manually. I'm reading the contributor guide but still wanted to submit the bug report now.
I also haven't had a chance to check out other fs API's like createReadStream, probably appropriate to have similar promisify support.
The text was updated successfully, but these errors were encountered: