Skip to content

Commit

Permalink
test: Update test-http-parser-free to use countdown timer
Browse files Browse the repository at this point in the history
PR-URL: #17322
Refs: #17169
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
daxlab authored and MylesBorins committed Dec 12, 2017
1 parent 4a749c3 commit b033d38
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions test/parallel/test-http-parser-free.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
require('../common');
const assert = require('assert');
const http = require('http');
const Countdown = require('../common/countdown');
const N = 100;
let responses = 0;

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

const countdown = new Countdown(N, () => server.close());

server.listen(0, function() {
http.globalAgent.maxSockets = 1;
let parser;
Expand All @@ -42,15 +44,9 @@ server.listen(0, function() {
assert.strictEqual(req.parser, parser);
}

if (++responses === N) {
server.close();
}
countdown.dec();
res.resume();
});
})(i);
}
});

process.on('exit', function() {
assert.strictEqual(responses, N);
});

0 comments on commit b033d38

Please sign in to comment.