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 6, 2021
1 parent d61977f commit 316d8c7
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 @@ -21,6 +21,7 @@

'use strict';
const common = require('../common');
const assert = require('assert');
const http = require('http');
const net = require('net');

Expand All @@ -43,6 +44,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 316d8c7

Please sign in to comment.