-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
pipeline await and toBuffer #2975
Comments
A Perhaps an alternative approach might be to const [pipe, buf] = await Promise.all([
pipeline(got.stream(uri), pil),
pil.toBuffer()
]); |
Yes ! that's so much nicer ! Even better, this works too:
maybe it would help so much if it was given as an example somewhere in the documentation. |
Glad you got it working. I've tagged this as |
I am trying to pipe an input stream to a sharp pipeline and get a buffer out of it.
To be able to handle the input stream errors, i thought i could do this:
however that doesn't work -
await pipeline
doesn't return when no error is thrown.On the other hand, it correctly (meaning
try { await getThumbnailBuffer(url); }
works) throws an error (from got.stream) when there is one.I also tried this but toBuffer is not a stream, so it can't work:
Instead i had to do that:
this works and also catches (in a way compatible with async/await) errors.
However it's ugly.
It's hard to tell if it comes from
but right now i'm inclined to think the need to call "toBuffer" to trigger the stream is odd.
The text was updated successfully, but these errors were encountered: