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.
Perry's P1 migration had to leave outbound TCP clients on tokio because
node:net'ssocket.upgradeToTLShands a live, already-connectedTcpStreamto a TLS layer mid-stream (PostgreSQL'sSSLRequestdoes 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.as_raw_fd) with documented rules about concurrent operations, which is weaker but enough forsocket._handle.fd.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.