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.

PR-URL: #38018
Fixes: #37291
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
lpinca committed Apr 8, 2021
1 parent 8d63aa8 commit cc4ee6c
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 cc4ee6c

Please sign in to comment.