fix(tsconnect/wasm): Node.js compatibility — safesocket unique name, listen addr normalisation #13
Reference in New Issue
Block a user
Delete Branch "wasm-node-fixes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two Go-side bugs found while making
@webnet/tsconnectwork in Node.js (see webnet/webnet#33).fix(safesocket/js): unique memconn name per IPN instance
safesocket_js.gohardcodedmemName = "Tailscale-IPN"for the in-memory IPC address. When a secondnewIPN()call was made in the same WASM process (e.g. two test nodes sharing a WASM instance), the secondsafesocket.Listen("")would fail withaddr unavailableandlog.Fatalthe entire WASM process.Fixed with an atomic counter: each listener gets a distinct name (
Tailscale-IPN-1,Tailscale-IPN-2, …). Theconnect()path is unchanged — in the tsconnect build all LocalAPI calls go through the in-processhttptesthandler andconnect()is never called.fix(tsconnect/wasm): normalise
:portlisten addr to0.0.0.0:portnetstack.ListenTCPrequires a fullhost:portaddress. Callers passing the standard Gonet.Listenform":0"(any-interface ephemeral port) receivedParseAddrPort(":0"): no IP. Thelisten()handler inwasm_js.gonow prepends"0.0.0.0"when the address starts with":", matching the behaviour ofnet.Listen.Test plan
🤖 Generated with Claude Code
codinget referenced this pull request from webnet/webnet2026-06-13 22:19:39 +02:00
netstack.ListenTCP requires a full host:port address; callers passing the standard net.Listen form (":0" for any-interface ephemeral port) would get ParseAddrPort error. Prepend "0.0.0.0" when the address starts with ":" so the API matches Go's net.Listen behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>cef1031b8eto4618ee1496