From 5493ae1fdcf85218a0dbd2c25789e41347f319d7 Mon Sep 17 00:00:00 2001 From: geek <wpreul@gmail.com> Date: Tue, 24 Jul 2018 04:25:26 -0500 Subject: [PATCH] Workaround node 10 regression --- lib/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 893ace9..a00e70b 100755 --- a/lib/index.js +++ b/lib/index.js @@ -332,14 +332,14 @@ internals.deferPipeUntilSocketConnects = function (req, stream) { const onSocket = (socket) => { - socket.on('connect', onSocketConnect); + socket.once('connect', onSocketConnect); }; const onSocketConnect = () => { stream.pipe(req); }; - req.on('socket', onSocket); + req.once('socket', onSocket); }; @@ -456,6 +456,14 @@ internals.Client.prototype._read = function (res, options, callback) { const onResAborted = () => { + // Workaround https://github.com/nodejs/node/pull/20611 + // This is covered in node 10 + /* $lab:coverage:off$ */ + if (res.complete) { + return; + } + /* $lab:coverage:on$ */ + return finishOnce(Boom.internal('Payload stream closed prematurely')); };