nock 14.0.15 → 14.0.16
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 +7 -0
- package/package.json +1 -1
package/lib/intercept.js
CHANGED
|
@@ -398,6 +398,13 @@ function activate() {
|
|
|
398
398
|
globalEmitter.emit('no match', nockRequest)
|
|
399
399
|
} else {
|
|
400
400
|
nockRequest.on('response', nockResponse => {
|
|
401
|
+
// Guard against the case where the AbortSignal fired before nock
|
|
402
|
+
// finished building the response. In that scenario the interceptor
|
|
403
|
+
// has already transitioned the request to an error state and calling
|
|
404
|
+
// controller.respondWith() would throw an InterceptorError.
|
|
405
|
+
if (mswRequest.signal.aborted) {
|
|
406
|
+
return
|
|
407
|
+
}
|
|
401
408
|
const response = createResponse(nockResponse, mswRequest.signal)
|
|
402
409
|
controller.respondWith(response)
|
|
403
410
|
})
|