We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c544194 commit fb33231Copy full SHA for fb33231
1 file changed
test/parallel/test-http-agent.js
@@ -21,6 +21,7 @@
21
22
'use strict';
23
const common = require('../common');
24
+const Countdown = require('../common/countdown');
25
const assert = require('assert');
26
const http = require('http');
27
common.crashOnUnhandledRejection();
@@ -33,14 +34,17 @@ const server = http.Server(common.mustCall(function(req, res) {
33
34
}, (N * M))); // N * M = good requests (the errors will not be counted)
35
36
function makeRequests(outCount, inCount, shouldFail) {
- let responseCount = outCount * inCount;
37
+ const countdown = new Countdown(
38
+ outCount * inCount,
39
+ common.mustCall(() => server.close())
40
+ );
41
let onRequest = common.mustNotCall(); // Temporary
42
const p = new Promise((resolve) => {
43
onRequest = common.mustCall((res) => {
- if (--responseCount === 0) {
- server.close();
44
+ if (countdown.dec() === 0) {
45
resolve();
46
}
47
+
48
if (!shouldFail)
49
res.resume();
50
}, outCount * inCount);
0 commit comments