Skip to content

Commit b122ca5

Browse files
pimterryaduh95
authored andcommitted
test: fix flaky http2 socket proxy test
Signed-off-by: Tim Perry <pimterry@gmail.com> PR-URL: #64673 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 8f415bf commit b122ca5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

test/parallel/test-http2-socket-proxy-destroy.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ if (!common.hasCrypto)
55
common.skip('missing crypto');
66
const assert = require('assert');
77
const h2 = require('http2');
8+
const Countdown = require('../common/countdown');
89

910
// Calling .destroy() on the socket proxy must not throw
1011
// (previously threw ERR_HTTP2_NO_SOCKET_MANIPULATION) and must
@@ -17,6 +18,8 @@ server.on('stream', common.mustCall(function(stream) {
1718
stream.end('ok');
1819
}, 2));
1920

21+
const countdown = new Countdown(2, () => server.close());
22+
2023
server.listen(0, common.mustCall(() => {
2124
const port = server.address().port;
2225

@@ -33,6 +36,7 @@ server.listen(0, common.mustCall(() => {
3336
assert.strictEqual(client.socket, undefined);
3437
// Destroying again through a stale proxy reference must not throw.
3538
socket.destroy();
39+
countdown.dec();
3640
}));
3741
}));
3842
client.on('error', common.mustNotCall());
@@ -51,7 +55,7 @@ server.listen(0, common.mustCall(() => {
5155
assert.strictEqual(err.message, 'boom');
5256
}));
5357
client.on('close', common.mustCall(() => {
54-
server.close();
58+
countdown.dec();
5559
}));
5660
}
5761
}));

0 commit comments

Comments
 (0)