feat(ext/net): add signal option to Deno.connect() (#27113)

Ref #26819

An optional **timeout** parameter has been added to the
**Deno.connect()** interface. This parameter allows specifying a timeout
(in milliseconds) within which the application must establish a
connection. If the timeout is exceeded without successfully connecting,
the operation is automatically aborted with an error. If the parameter
is not provided, the default behavior remains unchanged (no timeout).
Currently, the timeout functionality is implemented only for TCP
connections. Other connection types are not affected by this change.

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
This commit is contained in:
ctrl+d 2025-04-25 16:55:50 +02:00 committed by GitHub
parent 1c6a2445c3
commit f9a024a748
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 14 deletions

View file

@ -339,7 +339,10 @@ declare namespace Deno {
*
* @default {"127.0.0.1"} */
hostname?: string;
/** The transport layer protocol to use. */
transport?: "tcp";
/** An {@linkcode AbortSignal} to close the tcp connection. */
signal?: AbortSignal;
}
/**