denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.44k stars 5.37k forks source link

Deno.connect() with timeout and/or AbortSignal #25265

Open egfx-notifications opened 2 months ago

egfx-notifications commented 2 months ago

I encountered a problem with Deno.connect() and graceful program exit (e.g. with a SIGINT signal handler). If the remote peer of a TCP connection does not answer the SYN, for example because it is filtered by a firewall, Deno awaits a connection timeout from the kernel which can be more than 2 minutes on default linux installations (based on /proc/sys/net/ipv4/tcp_syn_retries). Exiting with Deno.exit() is still possible, of course, but it skips any shutdown and abort handlers defined in the application.

Can Deno.connect() be adjusted to accept either an AbortSignal or a custom timeout value?

lucacasonato commented 2 months ago

This seems very reasonable.