-
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
Docs: add exception handling examples in stream #4491
Comments
ping @nodejs/documentation :) |
I think that's just a wrong expectation. Core generally avoids behaviour changes like converting a thrown error to an emitted one. If the throw happened in an async thing within the through handler it'd be outside what try/catch can handle, placing it in domains territory, which we'd like to avoid. Not sure how exactly that should be expressed in documentation though. |
Yeah, I don't want to change the behaviour. Just adding docs :) Sent from my iPhone
|
@stevemao I'd love to see your understanding of this behavior written up and submitted as a PR. :) |
I can try. But it would take longer for me than people who already know how it internally works. |
👍 in documenting this. It is obvious for the seasoned node devs, but really frustrating for newbies. Also you need to document that errors are not propagated through the stream chain: var error = new Error('some error');
stream
.pipe(through2(function(chunk, enc, cb) {
cb(null, chunk)
}))
.on('error', function(err) {
// this will never happen
assert.equal(error, err);
});
stream.emit('error', error) and you should use pump. |
Hmmm.. at first blush, this seems like maybe a good first contribution, but then a quick look at nodejs/docs#82 suggests that maybe this requires an experienced contributor with a thick skin. Thoughts or volunteers on making this happen? |
@mafintosh @mcollina is this resolved due to adding pump? |
Yes, I think so. |
It is tempting to do something like this:
For me because in promise throwing an exception equals rejection.
The docs should tell what really happens when exceptions are thrown in these kind of functions (
_read
,_write
,_writev
,_transform
,_flush
).The text was updated successfully, but these errors were encountered: