Skip to content

Commit

Permalink
fix(test): Avoid EPIPE error in "web-ext sign" test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob--W authored and rpl committed Jul 16, 2018
1 parent 4134812 commit bc4eb1c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/functional/fake-amo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit bc4eb1c

Please sign in to comment.