@nxtedition/nxt-undici 6.1.6 → 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.
Files changed (2) hide show
  1. package/lib/utils.js +6 -3
  2. package/package.json +1 -1
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "6.1.6",
3
+ "version": "6.1.7",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",