@nxtedition/nxt-undici 2.0.29 → 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.
- package/lib/index.js +2 -2
- package/lib/readable.js +10 -8
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -185,7 +185,7 @@ export async function request(url, opts) {
|
|
|
185
185
|
if (statusCode !== 101) {
|
|
186
186
|
this.abort(createError(statusCode, { headers }))
|
|
187
187
|
} else {
|
|
188
|
-
this.resolve({ headers, socket })
|
|
188
|
+
this.resolve?.({ headers, socket })
|
|
189
189
|
this.resolve = null
|
|
190
190
|
}
|
|
191
191
|
},
|
|
@@ -214,7 +214,7 @@ export async function request(url, opts) {
|
|
|
214
214
|
size: Number.isFinite(contentLength) ? contentLength : null,
|
|
215
215
|
})
|
|
216
216
|
|
|
217
|
-
this.resolve(this.body)
|
|
217
|
+
this.resolve?.(this.body)
|
|
218
218
|
this.resolve = null
|
|
219
219
|
this.reject = null
|
|
220
220
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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) {
|