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 3, 2021
1 parent 3ef9562 commit 93ce076
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 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,14 @@ 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. The `'EPIPE'` and `'ECONNABORTED'` codes might also be
// valid but they have not been seen yet.
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 93ce076

Please sign in to comment.