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

tls: make tls.connect() accept a timeout option #25517

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
7 participants
@lpinca
Copy link
Member

lpinca commented Jan 15, 2019

If specified, and only when a socket is created internally, the option
will make socket.setTimeout() to be called on the created socket with
the given timeout.

This is consistent with the timeout option of net.connect() and
prevents the timeout option of the https.Agent from being ignored
when a socket is created.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
@nodejs-github-bot

This comment has been minimized.

Copy link

nodejs-github-bot commented Jan 15, 2019

@lpinca sadly an error occured when I tried to trigger a build :(

@@ -1023,6 +1023,9 @@ being issued by trusted CA (`options.ca`).
<!-- YAML
added: v0.11.3
changes:
- version: REPLACEME
pr-url: REPLACEME

This comment has been minimized.

@cjihrig

cjihrig Jan 15, 2019

Contributor

https://github.com/nodejs/node/pull/25517. Just pointing it out because I know it's easy to forget.

This comment has been minimized.

@lpinca

lpinca Jan 15, 2019

Author Member

Yes will do just wasn't sure what id to use before submitting.

@@ -1088,6 +1091,9 @@ changes:
`tls.createSecureContext()`.
* `lookup`: {Function} Custom lookup function. **Default:**
[`dns.lookup()`][].
* `timeout`: {number} If set and if a socket is created internally, will call
`socket.setTimeout(timeout)` after the socket is created, but before it

This comment has been minimized.

@sam-github

sam-github Jan 15, 2019

Member

maybe hyperlink to the setTimeout docs?

tls: make tls.connect() accept a timeout option
If specified, and only when a socket is created internally, the option
will make `socket.setTimeout()` to be called on the created socket with
the given timeout.

This is consistent with the `timeout` option of `net.connect()` and
prevents the `timeout` option of the `https.Agent` from being ignored
when a socket is created.

@lpinca lpinca force-pushed the lpinca:add/timeout-option branch from cad7708 to 7c158bf Jan 15, 2019

@@ -1256,6 +1256,11 @@ exports.connect = function connect(...args) {
localAddress: options.localAddress,
lookup: options.lookup
};

if (options.timeout) {

This comment has been minimized.

@silverwind

silverwind Jan 15, 2019

Contributor

typeof options.timeout === 'number' to allow setting a timeout of 0.

This comment has been minimized.

@lpinca

lpinca Jan 15, 2019

Author Member

0 == disabled idle timeout so I'm not sure if it's very useful. I mean it's like not setting it at all.

This comment has been minimized.

@silverwind

silverwind Jan 15, 2019

Contributor

Right, keep it as is.

This comment has been minimized.

@sam-github

sam-github Jan 15, 2019

Member

This code for tls.connect() is identical to that in net.connect(),

node/lib/net.js

Lines 158 to 160 in 2c7f4f4

if (options.timeout) {
socket.setTimeout(options.timeout);
}
, which is what I'd expect, so LGTM as is.

@lpinca

This comment has been minimized.

Copy link
Member Author

lpinca commented Jan 16, 2019

@lpinca

This comment has been minimized.

Copy link
Member Author

lpinca commented Jan 20, 2019

@lpinca

This comment has been minimized.

Copy link
Member Author

lpinca commented Jan 20, 2019

Landed in aaa7547.

@lpinca lpinca closed this Jan 20, 2019

@lpinca lpinca deleted the lpinca:add/timeout-option branch Jan 20, 2019

lpinca added a commit that referenced this pull request Jan 20, 2019

tls: make tls.connect() accept a timeout option
If specified, and only when a socket is created internally, the option
will make `socket.setTimeout()` to be called on the created socket with
the given timeout.

This is consistent with the `timeout` option of `net.connect()` and
prevents the `timeout` option of the `https.Agent` from being ignored
when a socket is created.

PR-URL: #25517
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

addaleax added a commit that referenced this pull request Jan 23, 2019

tls: make tls.connect() accept a timeout option
If specified, and only when a socket is created internally, the option
will make `socket.setTimeout()` to be called on the created socket with
the given timeout.

This is consistent with the `timeout` option of `net.connect()` and
prevents the `timeout` option of the `https.Agent` from being ignored
when a socket is created.

PR-URL: #25517
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>

MylesBorins added a commit that referenced this pull request Jan 24, 2019

2019-01-224, Version 11.8.0 (Current)
Notable Changes:

* events:
  * For unhandled `error` events with an argument that is not an
    `Error` object, the resulting exeption will have more information
    about the argument.
    #25621
* child_process:
  * When the `maxBuffer` option is passed, `stdout` and `stderr` will
    be truncated rather than unavailable in case of an error.
    #24951
* policy:
  * Experimental support for module integrity checks through a manifest
    file is implemented now.
    #23834
* n-api:
  * The `napi_threadsafe_function` feature is now stable.
    #25556
* report:
  * An experimental diagnostic API for capturing process state is
    available as `process.report` and through command line flags.
    #22712
* tls:
  * `tls.connect()` takes a `timeout` option analogous to the
    `net.connect()` one.
    #25517
* worker:
  * `process.umask()` is available as a read-only function inside Worker
    threads now.
    #25526
  * An `execArgv` option that supports a subset of Node.js command line
    options is supported now.
    #25467

PR-URL: Coming Soon

@MylesBorins MylesBorins referenced this pull request Jan 24, 2019

Merged

v11.8.0 proposal #25687

MylesBorins added a commit that referenced this pull request Jan 24, 2019

2019-01-224, Version 11.8.0 (Current)
Notable Changes:

* events:
  * For unhandled `error` events with an argument that is not an
    `Error` object, the resulting exeption will have more information
    about the argument.
    #25621
* child_process:
  * When the `maxBuffer` option is passed, `stdout` and `stderr` will
    be truncated rather than unavailable in case of an error.
    #24951
* policy:
  * Experimental support for module integrity checks through a manifest
    file is implemented now.
    #23834
* n-api:
  * The `napi_threadsafe_function` feature is now stable.
    #25556
* report:
  * An experimental diagnostic API for capturing process state is
    available as `process.report` and through command line flags.
    #22712
* tls:
  * `tls.connect()` takes a `timeout` option analogous to the
    `net.connect()` one.
    #25517
* worker:
  * `process.umask()` is available as a read-only function inside Worker
    threads now.
    #25526
  * An `execArgv` option that supports a subset of Node.js command line
    options is supported now.
    #25467

PR-URL: #25687

MylesBorins added a commit that referenced this pull request Jan 24, 2019

2019-01-24, Version 11.8.0 (Current)
Notable Changes:

* events:
  * For unhandled `error` events with an argument that is not an
    `Error` object, the resulting exeption will have more information
    about the argument.
    #25621
* child_process:
  * When the `maxBuffer` option is passed, `stdout` and `stderr` will
    be truncated rather than unavailable in case of an error.
    #24951
* policy:
  * Experimental support for module integrity checks through a manifest
    file is implemented now.
    #23834
* n-api:
  * The `napi_threadsafe_function` feature is now stable.
    #25556
* report:
  * An experimental diagnostic API for capturing process state is
    available as `process.report` and through command line flags.
    #22712
* tls:
  * `tls.connect()` takes a `timeout` option analogous to the
    `net.connect()` one.
    #25517
* worker:
  * `process.umask()` is available as a read-only function inside Worker
    threads now.
    #25526
  * An `execArgv` option that supports a subset of Node.js command line
    options is supported now.
    #25467

PR-URL: #25687

MylesBorins added a commit that referenced this pull request Jan 24, 2019

2019-01-24, Version 11.8.0 (Current)
Notable Changes:

* events:
  * For unhandled `error` events with an argument that is not an
    `Error` object, the resulting exeption will have more information
    about the argument.
    #25621
* child_process:
  * When the `maxBuffer` option is passed, `stdout` and `stderr` will
    be truncated rather than unavailable in case of an error.
    #24951
* policy:
  * Experimental support for module integrity checks through a manifest
    file is implemented now.
    #23834
* n-api:
  * The `napi_threadsafe_function` feature is now stable.
    #25556
* report:
  * An experimental diagnostic API for capturing process state is
    available as `process.report` and through command line flags.
    #22712
* tls:
  * `tls.connect()` takes a `timeout` option analogous to the
    `net.connect()` one.
    #25517
* worker:
  * `process.umask()` is available as a read-only function inside Worker
    threads now.
    #25526
  * An `execArgv` option that supports a subset of Node.js command line
    options is supported now.
    #25467

PR-URL: #25687

MylesBorins added a commit that referenced this pull request Jan 25, 2019

2019-01-24, Version 11.8.0 (Current)
Notable Changes:

* events:
  * For unhandled `error` events with an argument that is not an
    `Error` object, the resulting exeption will have more information
    about the argument.
    #25621
* child_process:
  * When the `maxBuffer` option is passed, `stdout` and `stderr` will
    be truncated rather than unavailable in case of an error.
    #24951
* policy:
  * Experimental support for module integrity checks through a manifest
    file is implemented now.
    #23834
* n-api:
  * The `napi_threadsafe_function` feature is now stable.
    #25556
* report:
  * An experimental diagnostic API for capturing process state is
    available as `process.report` and through command line flags.
    #22712
* tls:
  * `tls.connect()` takes a `timeout` option analogous to the
    `net.connect()` one.
    #25517
* worker:
  * `process.umask()` is available as a read-only function inside Worker
    threads now.
    #25526
  * An `execArgv` option that supports a subset of Node.js command line
    options is supported now.
    #25467

PR-URL: #25687
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment