Skip to content

Commit f3c1158

Browse files
daxlabgibfahn
authored andcommitted
test: Update test-http-parser-free to use countdown timer
PR-URL: #17322 Refs: #17169 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 956198f commit f3c1158

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

test/parallel/test-http-parser-free.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
require('../common');
33
const assert = require('assert');
44
const http = require('http');
5+
const Countdown = require('../common/countdown');
56
const N = 100;
6-
let responses = 0;
77

88
const server = http.createServer(function(req, res) {
99
res.end('Hello');
1010
});
1111

12+
const countdown = new Countdown(N, () => server.close());
13+
1214
server.listen(0, function() {
1315
http.globalAgent.maxSockets = 1;
1416
let parser;
@@ -21,15 +23,9 @@ server.listen(0, function() {
2123
assert.strictEqual(req.parser, parser);
2224
}
2325

24-
if (++responses === N) {
25-
server.close();
26-
}
26+
countdown.dec();
2727
res.resume();
2828
});
2929
})(i);
3030
}
3131
});
32-
33-
process.on('exit', function() {
34-
assert.strictEqual(responses, N);
35-
});

0 commit comments

Comments
 (0)