@@ -276,7 +276,3 @@ 'use strict' | ||
| const bodyAsStream = convertBodyToStream(rawBody) | ||
| // `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() | ||
| bodyAsStream.pause() | ||
@@ -287,7 +283,3 @@ // IncomingMessage extends Readable so we can't simply pipe. | ||
| }) | ||
| bodyAsStream.on('error', function (err) { | ||
| response.emit('error', err) | ||
| }) | ||
| function emitEnd() { | ||
| bodyAsStream.on('end', function () { | ||
| // https://nodejs.org/dist/latest-v10.x/docs/api/http.html#http_message_complete | ||
@@ -298,3 +290,6 @@ response.complete = true | ||
| interceptor.scope.emit('replied', req, interceptor) | ||
| } | ||
| }) | ||
| bodyAsStream.on('error', function (err) { | ||
| response.emit('error', err) | ||
| }) | ||
@@ -317,13 +312,3 @@ const { delayBodyInMs, delayConnectionInMs } = interceptor | ||
| // 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) | ||
| } | ||
| common.setTimeout(() => bodyAsStream.resume(), delayBodyInMs) | ||
| } | ||
@@ -330,0 +315,0 @@ |
+1
-1
@@ -10,3 +10,3 @@ { | ||
| ], | ||
| "version": "14.0.14", | ||
| "version": "14.0.15", | ||
| "author": "Pedro Teixeira <pedro.teixeira@gmail.com>", | ||
@@ -13,0 +13,0 @@ "repository": { |
184870
-0.34%3592
-0.39%