🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

nock

Package Overview
Dependencies
Maintainers
4
Versions
468
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nock - npm Package Compare versions

Comparing version
14.0.13
to
14.0.14
+22
-7
lib/playback_interceptor.js

@@ -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 @@

@@ -10,3 +10,3 @@ {

],
"version": "14.0.13",
"version": "14.0.14",
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",

@@ -13,0 +13,0 @@ "repository": {