@nxtedition/nxt-undici 6.1.5 → 6.1.7
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/cache.js +17 -13
- package/lib/utils.js +6 -3
- package/package.json +1 -1
package/lib/interceptor/cache.js
CHANGED
|
@@ -190,22 +190,26 @@ export default () => (dispatch) => (opts, handler) => {
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
handler.onHeaders(statusCode, headers, NOOP)
|
|
199
|
-
if (aborted) {
|
|
200
|
-
return
|
|
201
|
-
}
|
|
193
|
+
try {
|
|
194
|
+
handler.onConnect(abort)
|
|
195
|
+
if (aborted) {
|
|
196
|
+
return
|
|
197
|
+
}
|
|
202
198
|
|
|
203
|
-
|
|
204
|
-
handler.onData(body)
|
|
199
|
+
handler.onHeaders(statusCode, headers, NOOP)
|
|
205
200
|
if (aborted) {
|
|
206
201
|
return
|
|
207
202
|
}
|
|
208
|
-
}
|
|
209
203
|
|
|
210
|
-
|
|
204
|
+
if (body?.byteLength) {
|
|
205
|
+
handler.onData(body)
|
|
206
|
+
if (aborted) {
|
|
207
|
+
return
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
handler.onComplete({})
|
|
212
|
+
} catch (err) {
|
|
213
|
+
abort(err)
|
|
214
|
+
}
|
|
211
215
|
}
|
package/lib/utils.js
CHANGED
|
@@ -202,6 +202,7 @@ export class DecoratorHandler {
|
|
|
202
202
|
#aborted = false
|
|
203
203
|
#errored = false
|
|
204
204
|
#completed = false
|
|
205
|
+
#abort
|
|
205
206
|
|
|
206
207
|
constructor(handler) {
|
|
207
208
|
if (typeof handler !== 'object' || handler === null) {
|
|
@@ -214,23 +215,26 @@ export class DecoratorHandler {
|
|
|
214
215
|
this.#aborted = false
|
|
215
216
|
this.#errored = false
|
|
216
217
|
this.#completed = false
|
|
218
|
+
this.#abort = abort
|
|
217
219
|
|
|
218
220
|
return this.#handler.onConnect?.((reason) => {
|
|
219
221
|
if (!this.#aborted && !this.#completed && !this.#errored) {
|
|
220
222
|
this.#aborted = true
|
|
221
|
-
abort(reason)
|
|
223
|
+
this.#abort(reason)
|
|
222
224
|
}
|
|
223
225
|
})
|
|
224
226
|
}
|
|
225
227
|
|
|
226
228
|
onUpgrade(statusCode, headers, socket) {
|
|
227
229
|
if (!this.#aborted && !this.#errored) {
|
|
230
|
+
assert(!this.#completed)
|
|
228
231
|
return this.#handler.onUpgrade?.(statusCode, headers, socket)
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
|
|
232
235
|
onHeaders(statusCode, headers, resume) {
|
|
233
236
|
if (!this.#aborted && !this.#errored) {
|
|
237
|
+
assert(!this.#completed)
|
|
234
238
|
return this.#handler.onHeaders?.(statusCode, headers, resume)
|
|
235
239
|
}
|
|
236
240
|
}
|
|
@@ -243,9 +247,8 @@ export class DecoratorHandler {
|
|
|
243
247
|
}
|
|
244
248
|
|
|
245
249
|
onComplete(trailers) {
|
|
246
|
-
if (!this.#aborted && !this.#completed) {
|
|
250
|
+
if (!this.#aborted && !this.#completed && !this.#errored) {
|
|
247
251
|
this.#completed = true
|
|
248
|
-
assert(!this.#errored)
|
|
249
252
|
return this.#handler.onComplete?.(trailers)
|
|
250
253
|
}
|
|
251
254
|
}
|