-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Imported from #47
In the case where
abort()is not caught inside a utility function, an error passed toabort()has to be handled at the source, or it will bubble up as an unhandled rejection. An unhandled rejection generally signals to the developer that they've done something quite wrong (Node will of course scold you severely for doing this!). And according to the Stream idiom, they have.
In the case where
abort()is caught inside a utility function (to pass it downstream), an error passed toabort()won't bubble upstream to the source, even though the "handling" that's taking place is trivial and not actually doing anything. In this case, anabort()error will simply be swallowed, and the developer won't see it so they won't be under the impression that they've handled anything incorrectly.
Technically, they really haven't, because swallowing an abort error is a valid response to it. But it is a surprising experience for the developer. It's one thing to have an error bubble up and not understand why—then at least there's something to understand. It's another to have an error get swallowed by the internal implementation before the developer can even learn about it.