Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 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,13 @@ server.listen(0, function() {
assert.strictEqual(req.parser, parser);
}

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

process.on('exit', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this check? Doesn't server.close() / end of execution from the Countdown mean we've already hit zero remaining?

cc @jasnell

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, the process.on('exit') can be removed.

assert.strictEqual(responses, N);
assert.strictEqual(0, countdown.remaining);
});