Skip to content

Commit f302bc1

Browse files
tniessenjuanarbol
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 9e815c5 commit f302bc1

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

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

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

17-
firstDelay = common.platformTimeout(firstDelay);
18-
secondDelay = common.platformTimeout(secondDelay);
19-
20-
console.log('performRequestWithDelay', firstDelay, secondDelay);
21-
2217
setTimeout(() => {
2318
client.write('Connection: ');
2419
}, firstDelay).unref();
@@ -29,14 +24,19 @@ function performRequestWithDelay(client, firstDelay, secondDelay) {
2924
}, firstDelay + secondDelay).unref();
3025
}
3126

32-
const server = createServer(common.mustCallAtLeast((req, res) => {
27+
const requestTimeout = common.platformTimeout(2000);
28+
const server = createServer({
29+
headersTimeout: 0,
30+
requestTimeout,
31+
keepAliveTimeout: 0,
32+
connectionsCheckingInterval: requestTimeout / 4
33+
}, common.mustCallAtLeast((req, res) => {
3334
res.writeHead(200, { 'Content-Type': 'text/plain' });
3435
res.end();
3536
}));
3637

3738
// 0 seconds is the default
3839
assert.strictEqual(server.requestTimeout, 0);
39-
const requestTimeout = common.platformTimeout(1000);
4040
server.requestTimeout = requestTimeout;
4141
assert.strictEqual(server.requestTimeout, requestTimeout);
4242

@@ -58,9 +58,7 @@ server.listen(0, common.mustCall(() => {
5858
'HTTP/1.1 200 OK'
5959
);
6060

61-
const defer = common.platformTimeout(server.requestTimeout * 1.5);
62-
63-
console.log('defer by', defer);
61+
const defer = requestTimeout * 1.5;
6462

6563
// Wait some time to make sure requestTimeout
6664
// does not interfere with keep alive

0 commit comments

Comments
 (0)