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.
- package/lib/intercept.js +11 -0
- 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
|
})
|