Skip to content

Commit

Permalink
doc: deprecate socket.connect
Browse files Browse the repository at this point in the history
`socket.connect` is subtly broken due to timing and
_undestroy issues. Discourage usage and ask users
to instead create a new socket instance.

Refs: #33203
  • Loading branch information
ronag committed May 1, 2020
1 parent 0413acc commit 76bf3dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,22 @@ Type: Documentation-only
Use [`request.destroy()`][] instead of [`request.abort()`][].
<a id="DEP0XXX"></a>
### DEP0XXX: Use `net.connect()` instead of re-using sockets through
`socket.connect()`
<!-- YAML
changes:
- version:
- REPLACEME
pr-url: https://github.com/nodejs/node/pull/33204
description: Documentation-only deprecation.
-->
Type: Documentation-only
Use [`net.connect()`][] instead of re-using sockets through
[`socket.connect()`][].
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
[`--throw-deprecation`]: cli.html#cli_throw_deprecation
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
Expand Down Expand Up @@ -2722,6 +2738,7 @@ Use [`request.destroy()`][] instead of [`request.abort()`][].
[`https.get()`]: https.html#https_https_get_options_callback
[`https.request()`]: https.html#https_https_request_options_callback
[`module.createRequire()`]: modules.html#modules_module_createrequire_filename
[`net.connect()`]: net.html#net_net_connect
[`os.networkInterfaces()`]: os.html#os_os_networkinterfaces
[`os.tmpdir()`]: os.html#os_os_tmpdir
[`process.env`]: process.html#process_process_env
Expand All @@ -2742,6 +2759,7 @@ Use [`request.destroy()`][] instead of [`request.abort()`][].
[`script.createCachedData()`]: vm.html#vm_script_createcacheddata
[`setInterval()`]: timers.html#timers_setinterval_callback_delay_args
[`setTimeout()`]: timers.html#timers_settimeout_callback_delay_args
[`socket.connect()`]: net.html#net_socket_connect
[`timeout.ref()`]: timers.html#timers_timeout_ref
[`timeout.refresh()`]: timers.html#timers_timeout_refresh
[`timeout.unref()`]: timers.html#timers_timeout_unref
Expand Down
5 changes: 5 additions & 0 deletions doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,11 @@ added: v0.5.3
The amount of bytes sent.

### `socket.connect()`
<!-- YAML
deprecated: REPLACEME
-->

> Stability: 0 - Deprecated: Use [`net.connect()`][] instead.
Initiate a connection on a given socket.

Expand Down

0 comments on commit 76bf3dd

Please sign in to comment.