You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No way to reclaim a socket's descriptor: blocks mid-stream TLS upgrade and socket._handle.fd #35
Perry's P1 migration had to leave outbound TCP clients on tokio because node:net's socket.upgradeToTLS hands a live, already-connected TcpStream to a TLS layer mid-stream (PostgreSQL's SSLRequest does exactly this, and Perry has a gap test for it). A turnloop socket owns its descriptor and exposes no way to get it back, in 0.1.0-alpha.2 or alpha.3, so the class of socket that might later be upgraded cannot start on turnloop at all — transport is fixed at creation.
Perry also cannot implement socket._handle.fd, which Node exposes.
Options to consider:
Detached::into_fd() / into_handle(): detach a quiescent handle (the detach path already exists) and hand ownership of the raw descriptor back to the host, with the loop guaranteeing no outstanding operations.
A borrowed accessor (as_raw_fd) with documented rules about concurrent operations, which is weaker but enough for socket._handle.fd.
TLS on turnloop as the real answer for the upgrade case (Perry P5 uses turnloop-tls), leaving 1 or 2 for the general handoff.
Whichever is chosen must keep exactly-once completion and the buffer-ownership contract: a handle with pending operations must not be handed out, and after handoff the loop must not touch it. Windows needs the equivalent for sockets and named pipes, WASI and web return Unsupported.
Implemented in #37 (merged 3a2d98e). Ownership leaves through the existing detach (which already cancels, drains the owed terminal completions and unregisters), then Detached::into_fd on Unix or into_socket/into_handle on Windows; Loop::raw_transport gives a documented reporting-only view for socket._handle.fd. WASI and web are Unsupported. Windows CI corrected the association question: an IOCP association lives on the underlying object and survives duplication, so a handed-off handle is used synchronously/non-blocking or with OVERLAPPED.hEvent | 1, and from_socket/from_handle + attach is the route back. Proved end to end by a rustls handshake on a handed-off descriptor after the loop was dropped — Perry's upgradeToTLS pattern.
Activity
Hand a quiescent handle's descriptor back to the host (#35) (#37)
proggeramlug commentedon Sep 15, 2026
Implemented in #37 (merged 3a2d98e). Ownership leaves through the existing
detach(which already cancels, drains the owed terminal completions and unregisters), thenDetached::into_fdon Unix orinto_socket/into_handleon Windows;Loop::raw_transportgives a documented reporting-only view forsocket._handle.fd. WASI and web areUnsupported. Windows CI corrected the association question: an IOCP association lives on the underlying object and survives duplication, so a handed-off handle is used synchronously/non-blocking or withOVERLAPPED.hEvent | 1, andfrom_socket/from_handle+attachis the route back. Proved end to end by a rustls handshake on a handed-off descriptor after the loop was dropped — Perry'supgradeToTLSpattern.