Skip to content

Commit f78ecc3

Browse files
mildsunriseBethGriggs
authored andcommitted
test: fix race in test-http2-origin
Backport-PR-URL: #28904 PR-URL: #28903 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 56a834a commit f78ecc3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/parallel/test-http2-origin.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
8888
['https://example.org', 'https://example.com']
8989
];
9090

91-
const countdown = new Countdown(2, () => {
91+
const countdown = new Countdown(3, () => {
9292
client.close();
9393
server.close();
9494
});
@@ -101,7 +101,7 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
101101
countdown.dec();
102102
}, 2));
103103

104-
client.request().on('close', mustCall()).resume();
104+
client.request().on('close', mustCall(() => countdown.dec())).resume();
105105
}));
106106
}
107107

@@ -119,15 +119,19 @@ const ca = readKey('fake-startcom-root-cert.pem', 'binary');
119119
const originSet = [`https://localhost:${server.address().port}`];
120120
const client = connect(originSet[0], { ca });
121121

122+
const countdown = new Countdown(2, () => {
123+
client.close();
124+
server.close();
125+
});
126+
122127
client.on('origin', mustCall((origins) => {
123128
originSet.push(...check);
124129
deepStrictEqual(originSet, client.originSet);
125130
deepStrictEqual(origins, check);
126-
client.close();
127-
server.close();
131+
countdown.dec();
128132
}));
129133

130-
client.request().on('close', mustCall()).resume();
134+
client.request().on('close', mustCall(() => countdown.dec())).resume();
131135
}));
132136
}
133137

0 commit comments

Comments
 (0)