Skip to content

Commit 37364ab

Browse files
tniessentargos
authored andcommitted
test: fix flaky HTTP server tests
Refs: #41263 PR-URL: #42846 Fixes: #42741 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
1 parent 0e16120 commit 37364ab

2 files changed

+6
-12
lines changed

test/parallel/test-http-server-headers-timeout-keepalive.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ function performRequestWithDelay(client, firstDelay, secondDelay, closeAfter) {
1414
client.resume();
1515
client.write('GET / HTTP/1.1\r\n');
1616

17-
firstDelay = common.platformTimeout(firstDelay);
18-
secondDelay = common.platformTimeout(secondDelay);
19-
2017
setTimeout(() => {
2118
client.write('Connection: ');
2219
}, firstDelay).unref();
@@ -27,12 +24,12 @@ function performRequestWithDelay(client, firstDelay, secondDelay, closeAfter) {
2724
}, firstDelay + secondDelay).unref();
2825
}
2926

30-
const headersTimeout = common.platformTimeout(1000);
27+
const headersTimeout = common.platformTimeout(2000);
3128
const server = createServer({
3229
headersTimeout,
3330
requestTimeout: 0,
3431
keepAliveTimeout: 0,
35-
connectionsCheckingInterval: common.platformTimeout(250),
32+
connectionsCheckingInterval: headersTimeout / 4,
3633
}, common.mustCallAtLeast((req, res) => {
3734
res.writeHead(200, { 'Content-Type': 'text/plain' });
3835
res.end();
@@ -60,7 +57,7 @@ server.listen(0, common.mustCall(() => {
6057
'HTTP/1.1 200 OK'
6158
);
6259

63-
const defer = common.platformTimeout(headersTimeout * 1.5);
60+
const defer = headersTimeout * 1.5;
6461

6562
// Wait some time to make sure headersTimeout
6663
// does not interfere with keep alive

test/parallel/test-http-server-request-timeout-keepalive.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ function performRequestWithDelay(client, firstDelay, secondDelay, closeAfter) {
1414
client.resume();
1515
client.write('GET / HTTP/1.1\r\n');
1616

17-
firstDelay = common.platformTimeout(firstDelay);
18-
secondDelay = common.platformTimeout(secondDelay);
19-
2017
setTimeout(() => {
2118
client.write('Connection: ');
2219
}, firstDelay).unref();
@@ -27,12 +24,12 @@ function performRequestWithDelay(client, firstDelay, secondDelay, closeAfter) {
2724
}, firstDelay + secondDelay).unref();
2825
}
2926

30-
const requestTimeout = common.platformTimeout(1000);
27+
const requestTimeout = common.platformTimeout(2000);
3128
const server = createServer({
3229
headersTimeout: 0,
3330
requestTimeout,
3431
keepAliveTimeout: 0,
35-
connectionsCheckingInterval: common.platformTimeout(250),
32+
connectionsCheckingInterval: requestTimeout / 4
3633
}, common.mustCallAtLeast((req, res) => {
3734
res.writeHead(200, { 'Content-Type': 'text/plain' });
3835
res.end();
@@ -58,7 +55,7 @@ server.listen(0, common.mustCall(() => {
5855
'HTTP/1.1 200 OK'
5956
);
6057

61-
const defer = common.platformTimeout(requestTimeout * 1.5);
58+
const defer = requestTimeout * 1.5;
6259

6360
// Wait some time to make sure requestTimeout
6461
// does not interfere with keep alive

0 commit comments

Comments
 (0)