From 8241289648821d0a85088ca35adb01001e78c03a Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Thu, 1 Apr 2021 14:57:16 +0200 Subject: [PATCH] test: deflake test-http-many-ended-pipelines The socket might be destroyed by the other peer while data is still being written. Add the missing error handler. Fixes: https://github.com/nodejs/node/issues/37291 --- test/parallel/test-http-many-ended-pipelines.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/parallel/test-http-many-ended-pipelines.js b/test/parallel/test-http-many-ended-pipelines.js index 20371e7e5627210..f1e3b31aef5966a 100644 --- a/test/parallel/test-http-many-ended-pipelines.js +++ b/test/parallel/test-http-many-ended-pipelines.js @@ -29,6 +29,7 @@ console.trace = function() { throw new Error('no tracing should happen here'); }; +const assert = require('assert'); const http = require('http'); const net = require('net'); @@ -51,6 +52,13 @@ const server = http.createServer(function(req, res) { server.listen(0, function() { const client = net.connect({ port: this.address().port, allowHalfOpen: true }); + + client.on('error', function(err) { + // The socket might be destroyed by the other peer while data is still + // being written. + assert.strictEqual(err.code, 'ECONNRESET'); + }); + for (let i = 0; i < numRequests; i++) { client.write('GET / HTTP/1.1\r\n' + 'Host: some.host.name\r\n' +