@nxtedition/nxt-undici 2.0.30 → 2.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/readable.js +10 -8
  2. package/package.json +1 -1
package/lib/readable.js CHANGED
@@ -88,15 +88,17 @@ export class BodyReadable extends Readable {
88
88
  this[kHandler].signal = null
89
89
  }
90
90
 
91
- // Workaround for Node "bug". If the stream is destroyed in same
92
- // tick as it is created, then a user who is waiting for a
93
- // promise (i.e micro tick) for installing a 'error' listener will
94
- // never get a chance and will always encounter an unhandled exception.
95
- // - tick => process.nextTick(fn)
96
- // - micro tick => queueMicrotask(fn)
97
- queueMicrotask(() => {
91
+ if (err) {
92
+ // Workaround for Node "bug". If the stream is destroyed in same
93
+ // tick as it is created, then a user who is waiting for a
94
+ // promise (i.e micro tick) for installing a 'error' listener will
95
+ // never get a chance and will always encounter an unhandled exception.
96
+ // - tick => process.nextTick(fn)
97
+ // - micro tick => queueMicrotask(fn)
98
+ setImmediate(() => callback(err))
99
+ } else {
98
100
  callback(err)
99
- })
101
+ }
100
102
  }
101
103
 
102
104
  on(ev, ...args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "2.0.30",
3
+ "version": "2.0.31",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",