Skip to content

Commit

Permalink
fix: defer errors with setImmediate
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Apr 10, 2024
1 parent cae5625 commit 0ac7a8e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/api/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class BodyReadable extends Readable {
// tick as it is created, then a user who is waiting for a
// promise (i.e micro tick) for installing a 'error' listener will
// never get a chance and will always encounter an unhandled exception.
// - tick => process.nextTick(fn)
// - micro tick => queueMicrotask(fn)
queueMicrotask(() => {
setImmediate(() => {
callback(err)
})
}
Expand Down

0 comments on commit 0ac7a8e

Please sign in to comment.