Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http, http2: remove default server timeout #27558

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1013,9 +1013,13 @@ Limits maximum incoming headers count. If set to 0, no limit will be applied.
### server.setTimeout([msecs][, callback])
<!-- YAML
added: v0.9.12
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/27558
description: The default timeout changed from 120s to 0 (no timeout).
-->

* `msecs` {number} **Default:** `120000` (2 minutes)
* `msecs` {number} **Default:** 0 (no timeout)
* `callback` {Function}
* Returns: {http.Server}

@@ -1026,16 +1030,20 @@ occurs.
If there is a `'timeout'` event listener on the Server object, then it
will be called with the timed-out socket as an argument.

By default, the Server's timeout value is 2 minutes, and sockets are
destroyed automatically if they time out. However, if a callback is assigned
to the Server's `'timeout'` event, timeouts must be handled explicitly.
By default, the Server does not timeout sockets. However, if a callback
is assigned to the Server's `'timeout'` event, timeouts must be handled
explicitly.

### server.timeout
<!-- YAML
added: v0.9.12
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/27558
description: The default timeout changed from 120s to 0 (no timeout).
-->

* {number} Timeout in milliseconds. **Default:** `120000` (2 minutes).
* {number} Timeout in milliseconds. **Default:** 0 (no timeout)

The number of milliseconds of inactivity before a socket is presumed
to have timed out.
@@ -1722,11 +1722,15 @@ server.on('stream', (stream, headers, flags) => {
#### Event: 'timeout'
<!-- YAML
added: v8.4.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/27558
description: The default timeout changed from 120s to 0 (no timeout).
-->

The `'timeout'` event is emitted when there is no activity on the Server for
a given number of milliseconds set using `http2server.setTimeout()`.
**Default:** 2 minutes.
**Default:** 0 (no timeout)

#### server.close([callback])
<!-- YAML
@@ -1743,9 +1747,13 @@ consider also using [`http2session.close()`] on active sessions.
#### server.setTimeout([msecs][, callback])
<!-- YAML
added: v8.4.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/27558
description: The default timeout changed from 120s to 0 (no timeout).
-->

* `msecs` {number} **Default:** `120000` (2 minutes)
* `msecs` {number} **Default:** 0 (no timeout)
* `callback` {Function}
* Returns: {Http2Server}

@@ -315,7 +315,7 @@ function Server(options, requestListener) {

this.on('connection', connectionListener);

this.timeout = 2 * 60 * 1000;
this.timeout = 0;
this.keepAliveTimeout = 5000;
this.maxHeadersCount = null;
this.headersTimeout = 40 * 1000; // 40 seconds
@@ -71,7 +71,7 @@ function Server(opts, requestListener) {
conn.destroy(err);
});

this.timeout = 2 * 60 * 1000;
This conversation was marked as resolved by ofrobots

This comment has been minimized.

Copy link
@Trott

Trott May 5, 2019

Member
Suggested change
this.timeout = 2 * 60 * 1000;
this.timeout = 0;
this.timeout = 0;
this.keepAliveTimeout = 5000;
this.maxHeadersCount = null;
this.headersTimeout = 40 * 1000; // 40 seconds
@@ -171,8 +171,6 @@ const kState = Symbol('state');
const kType = Symbol('type');
const kWriteGeneric = Symbol('write-generic');

const kDefaultSocketTimeout = 2 * 60 * 1000;
This conversation was marked as resolved by ofrobots

This comment has been minimized.

Copy link
@Trott

Trott May 5, 2019

Member
Suggested change
const kDefaultSocketTimeout = 2 * 60 * 1000;
const kDefaultSocketTimeout = 0;

const {
paddingBuffer,
PADDING_BUF_FRAME_LENGTH,
@@ -2680,7 +2678,7 @@ class Http2SecureServer extends TLSServer {
options = initializeTLSOptions(options);
super(options, connectionListener);
this[kOptions] = options;
this.timeout = kDefaultSocketTimeout;
This conversation was marked as resolved by ofrobots

This comment has been minimized.

Copy link
@Trott

Trott May 5, 2019

Member
Suggested change
this.timeout = kDefaultSocketTimeout;
this.timeout = 0;

...or if kDefaultSocketTimeout is set to 0, leave the line as-is?

this.timeout = 0;
this.on('newListener', setupCompat);
if (typeof requestListener === 'function')
this.on('request', requestListener);
@@ -2702,7 +2700,7 @@ class Http2Server extends NETServer {
constructor(options, requestListener) {
super(connectionListener);
this[kOptions] = initializeOptions(options);
this.timeout = kDefaultSocketTimeout;
This conversation was marked as resolved by ofrobots

This comment has been minimized.

Copy link
@Trott

Trott May 5, 2019

Member
Suggested change
this.timeout = kDefaultSocketTimeout;
this.timeout = 0;

...or if kDefaultSocketTimeout is set to 0, leave the line as-is?

this.timeout = 0;
this.on('newListener', setupCompat);
if (typeof requestListener === 'function')
this.on('request', requestListener);
@@ -43,9 +43,6 @@ process.on('exit', function() {
{ type: 'HTTPINCOMINGMESSAGE',
id: 'httpincomingmessage:1',
triggerAsyncId: 'tcp:2' },
{ type: 'Timeout',
id: 'timeout:2',
triggerAsyncId: 'tcp:2' },
{ type: 'SHUTDOWNWRAP',
id: 'shutdown:1',
triggerAsyncId: 'tcp:2' } ]
@@ -46,7 +46,7 @@ server.listen(0, common.mustCall(() => {
}, common.mustCall((res) => {
res.on('data', () => {});
res.on('end', common.mustCall(() => {
assert.strictEqual(socket[kTimeout]._idleTimeout, -1);
assert.strictEqual(socket[kTimeout], null);
assert.strictEqual(socket.parser, null);
assert.strictEqual(socket._httpMessage, null);
}));
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.