Skip to content

Commit

Permalink
test: deflake test-http-many-ended-pipelines
Browse files Browse the repository at this point in the history
The socket might be destroyed by the other peer while data is still
being written. Add the missing error handler.

Fixes: #37291
  • Loading branch information
lpinca committed Apr 1, 2021
1 parent 3ef9562 commit 8241289
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/parallel/test-http-many-ended-pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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' +
Expand Down

0 comments on commit 8241289

Please sign in to comment.