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 <me@jonathanmoss.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
daxlab authored and MylesBorins committed Dec 11, 2017
1 parent 7f8f607 commit a7455f7
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 a7455f7

Please sign in to comment.