Skip to content

Commit 50690e9

Browse files
committed
test: fix flaky HTTP server tests
Refs: nodejs#41263
1 parent e2ff1c3 commit 50690e9

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)