nock 14.0.15 → 14.0.17

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/intercept.js +11 -0
  2. package/package.json +1 -1
package/lib/intercept.js CHANGED
@@ -236,6 +236,10 @@ function removeInterceptor(options) {
236
236
  ) {
237
237
  allInterceptors[baseUrl].interceptors.splice(i, 1)
238
238
  interceptor.scope.remove(key, interceptor)
239
+ interceptor.scope.interceptors.splice(
240
+ interceptor.scope.interceptors.indexOf(interceptor),
241
+ 1,
242
+ )
239
243
  break
240
244
  }
241
245
  }
@@ -398,6 +402,13 @@ function activate() {
398
402
  globalEmitter.emit('no match', nockRequest)
399
403
  } else {
400
404
  nockRequest.on('response', nockResponse => {
405
+ // Guard against the case where the AbortSignal fired before nock
406
+ // finished building the response. In that scenario the interceptor
407
+ // has already transitioned the request to an error state and calling
408
+ // controller.respondWith() would throw an InterceptorError.
409
+ if (mswRequest.signal.aborted) {
410
+ return
411
+ }
401
412
  const response = createResponse(nockResponse, mswRequest.signal)
402
413
  controller.respondWith(response)
403
414
  })
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "testing",
8
8
  "isolation"
9
9
  ],
10
- "version": "14.0.15",
10
+ "version": "14.0.17",
11
11
  "author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
12
12
  "repository": {
13
13
  "type": "git",