Skip to content

Commit e0e39c6

Browse files
committed
test: reduce flakiness of test-http-remove-header-stays-removed.js
Refs: nodejs/reliability#508 Refs: nodejs#46333
1 parent fadcee7 commit e0e39c6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/parallel/test-http-remove-header-stays-removed.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
require('../common');
23+
const common = require('../common');
2424
const assert = require('assert');
2525

2626
const http = require('http');
@@ -54,13 +54,14 @@ server.listen(0, function() {
5454
res.setEncoding('ascii');
5555
res.on('data', function(chunk) {
5656
response += chunk;
57+
if (response?.toString() === 'beep boop\n') {
58+
setTimeout(function() {
59+
// The socket should be closed immediately, with no keep-alive, because
60+
// no content-length or transfer-encoding are used:
61+
assert.strictEqual(res.socket.closed, true);
62+
server.close();
63+
}, common.platformTimeout(15));
64+
}
5765
});
58-
59-
setTimeout(function() {
60-
// The socket should be closed immediately, with no keep-alive, because
61-
// no content-length or transfer-encoding are used:
62-
assert.strictEqual(res.socket.closed, true);
63-
server.close();
64-
}, 10);
6566
});
6667
});

0 commit comments

Comments
 (0)