@@ -276,3 +276,7 @@ 'use strict' | ||
| const bodyAsStream = convertBodyToStream(rawBody) | ||
| bodyAsStream.pause() | ||
| // `replyWithFile` and similar reply callbacks hand back a paused stream, | ||
| // so force flowing mode here. `delayBody` gates only the end-of-response | ||
| // signal below; a slow body must present as a slow body — read timeouts | ||
| // on the response can fire — instead of as a slow connection. | ||
| bodyAsStream.resume() | ||
@@ -283,3 +287,7 @@ // IncomingMessage extends Readable so we can't simply pipe. | ||
| }) | ||
| bodyAsStream.on('end', function () { | ||
| bodyAsStream.on('error', function (err) { | ||
| response.emit('error', err) | ||
| }) | ||
| function emitEnd() { | ||
| // https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_message_complete | ||
@@ -290,6 +298,3 @@ response.complete = true | ||
| interceptor.scope.emit('replied', req, interceptor) | ||
| }) | ||
| bodyAsStream.on('error', function (err) { | ||
| response.emit('error', err) | ||
| }) | ||
| } | ||
@@ -312,3 +317,13 @@ const { delayBodyInMs, delayConnectionInMs } = interceptor | ||
| common.setTimeout(() => bodyAsStream.resume(), delayBodyInMs) | ||
| // Apply the body delay only after the response event has been emitted | ||
| // and the body source has finished, so `delay({ head, body })` | ||
| // compounds the two waits. | ||
| function scheduleEnd() { | ||
| common.setTimeout(emitEnd, delayBodyInMs) | ||
| } | ||
| if (bodyAsStream.readableEnded) { | ||
| scheduleEnd() | ||
| } else { | ||
| bodyAsStream.once('end', scheduleEnd) | ||
| } | ||
| } | ||
@@ -315,0 +330,0 @@ |
+1
-1
@@ -10,3 +10,3 @@ { | ||
| ], | ||
| "version": "14.0.13", | ||
| "version": "14.0.14", | ||
| "author": "Pedro Teixeira <pedro.teixeira@gmail.com>", | ||
@@ -13,0 +13,0 @@ "repository": { |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
185492
0.34%3606
0.39%