From 3b560fda92e7d3d5dd642cc26ced3e400add9624 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Mon, 16 Jul 2018 18:04:13 +0200 Subject: [PATCH] fix(test): Avoid EPIPE error in "web-ext sign" test --- tests/functional/fake-amo-server.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/functional/fake-amo-server.js b/tests/functional/fake-amo-server.js index ce8bbf4dec..d2676209a6 100755 --- a/tests/functional/fake-amo-server.js +++ b/tests/functional/fake-amo-server.js @@ -29,9 +29,17 @@ http.createServer(function(req, res) { const reply = FAKE_REPLIES[replyIndex++]; if (reply) { - res.writeHead(200, {'content-type': 'application/json'}); - res.write(JSON.stringify(reply)); - res.end(); + req.on('data', function() { + // Ignore request body. + }); + // Wait for the transfer of the request body to finish before sending a response. + // Otherwise the client could experience an EPIPE error: + // https://github.com/nodejs/node/issues/12339 + req.once('end', function() { + res.writeHead(200, {'content-type': 'application/json'}); + res.write(JSON.stringify(reply)); + res.end(); + }); } else { process.exit(1); }