Skip to content

Commit 76bf3dd

Browse files
committed
doc: deprecate socket.connect
`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
1 parent 0413acc commit 76bf3dd

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

doc/api/deprecations.md

+18
Original file line numberDiff line numberDiff line change
@@ -2668,6 +2668,22 @@ Type: Documentation-only
26682668
26692669
Use [`request.destroy()`][] instead of [`request.abort()`][].
26702670
2671+
<a id="DEP0XXX"></a>
2672+
### DEP0XXX: Use `net.connect()` instead of re-using sockets through
2673+
`socket.connect()`
2674+
<!-- YAML
2675+
changes:
2676+
- version:
2677+
- REPLACEME
2678+
pr-url: https://github.com/nodejs/node/pull/33204
2679+
description: Documentation-only deprecation.
2680+
-->
2681+
2682+
Type: Documentation-only
2683+
2684+
Use [`net.connect()`][] instead of re-using sockets through
2685+
[`socket.connect()`][].
2686+
26712687
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
26722688
[`--throw-deprecation`]: cli.html#cli_throw_deprecation
26732689
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
@@ -2722,6 +2738,7 @@ Use [`request.destroy()`][] instead of [`request.abort()`][].
27222738
[`https.get()`]: https.html#https_https_get_options_callback
27232739
[`https.request()`]: https.html#https_https_request_options_callback
27242740
[`module.createRequire()`]: modules.html#modules_module_createrequire_filename
2741+
[`net.connect()`]: net.html#net_net_connect
27252742
[`os.networkInterfaces()`]: os.html#os_os_networkinterfaces
27262743
[`os.tmpdir()`]: os.html#os_os_tmpdir
27272744
[`process.env`]: process.html#process_process_env
@@ -2742,6 +2759,7 @@ Use [`request.destroy()`][] instead of [`request.abort()`][].
27422759
[`script.createCachedData()`]: vm.html#vm_script_createcacheddata
27432760
[`setInterval()`]: timers.html#timers_setinterval_callback_delay_args
27442761
[`setTimeout()`]: timers.html#timers_settimeout_callback_delay_args
2762+
[`socket.connect()`]: net.html#net_socket_connect
27452763
[`timeout.ref()`]: timers.html#timers_timeout_ref
27462764
[`timeout.refresh()`]: timers.html#timers_timeout_refresh
27472765
[`timeout.unref()`]: timers.html#timers_timeout_unref

doc/api/net.md

+5
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,11 @@ added: v0.5.3
581581
The amount of bytes sent.
582582

583583
### `socket.connect()`
584+
<!-- YAML
585+
deprecated: REPLACEME
586+
-->
587+
588+
> Stability: 0 - Deprecated: Use [`net.connect()`][] instead.
584589
585590
Initiate a connection on a given socket.
586591

0 commit comments

Comments
 (0)