@nxtedition/nxt-undici 2.0.35 → 2.0.37
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/interceptor/log.js +14 -2
- package/lib/readable.js +31 -21
- package/package.json +1 -1
package/lib/interceptor/log.js
CHANGED
|
@@ -79,12 +79,24 @@ class Handler {
|
|
|
79
79
|
|
|
80
80
|
if (this.aborted) {
|
|
81
81
|
this.logger.debug(
|
|
82
|
-
{
|
|
82
|
+
{
|
|
83
|
+
ureq: this.opts,
|
|
84
|
+
bytesRead: this.pos,
|
|
85
|
+
elapsedTime: this.stats.end,
|
|
86
|
+
stats: this.stats,
|
|
87
|
+
err,
|
|
88
|
+
},
|
|
83
89
|
'upstream request aborted',
|
|
84
90
|
)
|
|
85
91
|
} else {
|
|
86
92
|
this.logger.error(
|
|
87
|
-
{
|
|
93
|
+
{
|
|
94
|
+
ureq: this.opts,
|
|
95
|
+
bytesRead: this.pos,
|
|
96
|
+
elapsedTime: this.stats.end,
|
|
97
|
+
stats: this.stats,
|
|
98
|
+
err,
|
|
99
|
+
},
|
|
88
100
|
'upstream request failed',
|
|
89
101
|
)
|
|
90
102
|
}
|
package/lib/readable.js
CHANGED
|
@@ -125,7 +125,7 @@ export class BodyReadable extends Readable {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
push(chunk) {
|
|
128
|
-
if (this[kConsume] && chunk !== null
|
|
128
|
+
if (this[kConsume] && chunk !== null) {
|
|
129
129
|
consumePush(this[kConsume], chunk)
|
|
130
130
|
return this[kReading] ? super.push(chunk) : true
|
|
131
131
|
}
|
|
@@ -232,26 +232,28 @@ async function consume(stream, type) {
|
|
|
232
232
|
reject(rState.errored ?? new TypeError('unusable'))
|
|
233
233
|
}
|
|
234
234
|
} else {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
235
|
+
queueMicrotask(() => {
|
|
236
|
+
stream[kConsume] = {
|
|
237
|
+
type,
|
|
238
|
+
stream,
|
|
239
|
+
resolve,
|
|
240
|
+
reject,
|
|
241
|
+
length: 0,
|
|
242
|
+
body: [],
|
|
243
|
+
}
|
|
243
244
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
245
|
+
stream
|
|
246
|
+
.on('error', function (err) {
|
|
247
|
+
consumeFinish(this[kConsume], err)
|
|
248
|
+
})
|
|
249
|
+
.on('close', function () {
|
|
250
|
+
if (this[kConsume].body !== null) {
|
|
251
|
+
consumeFinish(this[kConsume], new RequestAbortedError())
|
|
252
|
+
}
|
|
253
|
+
})
|
|
253
254
|
|
|
254
|
-
|
|
255
|
+
consumeStart(stream[kConsume])
|
|
256
|
+
})
|
|
255
257
|
}
|
|
256
258
|
})
|
|
257
259
|
}
|
|
@@ -263,8 +265,16 @@ function consumeStart(consume) {
|
|
|
263
265
|
|
|
264
266
|
const { _readableState: state } = consume.stream
|
|
265
267
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
+
if (state.bufferIndex) {
|
|
269
|
+
const start = state.bufferIndex
|
|
270
|
+
const end = state.buffer.length
|
|
271
|
+
for (let n = start; n < end; n++) {
|
|
272
|
+
consumePush(consume, state.buffer[n])
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
for (const chunk of state.buffer) {
|
|
276
|
+
consumePush(consume, chunk)
|
|
277
|
+
}
|
|
268
278
|
}
|
|
269
279
|
|
|
270
280
|
if (state.endEmitted) {
|