Skip to content

Commit

Permalink
doc,test: add server.timeout property to http2 public API
Browse files Browse the repository at this point in the history
Both http and https modules have server.timeout property
in public API. This commit adds documentation section and test
for server.timeout in http2 module, so it becomes consistent
with http and https.

Also improves description of callback argument in documentation
for server.setTimeout().
  • Loading branch information
puzpuzpuz committed Feb 8, 2020
1 parent 8a14884 commit 661fd6b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
42 changes: 40 additions & 2 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1797,9 +1797,28 @@ on the `Http2Server` after `msecs` milliseconds.

The given callback is registered as a listener on the `'timeout'` event.

In case of no callback function were assigned, a new `ERR_INVALID_CALLBACK`
In case if `callback` is not a function, a new `ERR_INVALID_CALLBACK`
error will be thrown.

#### `server.timeout`
<!-- YAML
added: v8.4.0
changes:
- version: v13.0.0
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:** 0 (no timeout)

The number of milliseconds of inactivity before a socket is presumed
to have timed out.

A value of `0` will disable the timeout behavior on incoming connections.

The socket timeout logic is set up on connection, so changing this
value only affects new connections to the server, not any existing connections.

### Class: `Http2SecureServer`
<!-- YAML
added: v8.4.0
Expand Down Expand Up @@ -1943,9 +1962,28 @@ on the `Http2SecureServer` after `msecs` milliseconds.

The given callback is registered as a listener on the `'timeout'` event.

In case of no callback function were assigned, a new `ERR_INVALID_CALLBACK`
In case if `callback` is not a function, a new `ERR_INVALID_CALLBACK`
error will be thrown.

#### `server.timeout`
<!-- YAML
added: v8.4.0
changes:
- version: v13.0.0
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:** 0 (no timeout)

The number of milliseconds of inactivity before a socket is presumed
to have timed out.

A value of `0` will disable the timeout behavior on incoming connections.

The socket timeout logic is set up on connection, so changing this
value only affects new connections to the server, not any existing connections.

### `http2.createServer(options[, onRequestHandler])`
<!-- YAML
added: v8.4.0
Expand Down
6 changes: 5 additions & 1 deletion test/parallel/test-http2-server-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const http2 = require('http2');

const server = http2.createServer();
server.setTimeout(common.platformTimeout(50));
server.setTimeout(42000);
assert.strictEqual(server.timeout, 42000);

server.timeout = common.platformTimeout(50);

const onServerTimeout = common.mustCall((session) => {
session.close();
Expand Down

0 comments on commit 661fd6b

Please sign in to comment.