fix(net): force IPv4 and disable Happy Eyeballs in Node entrypoints#2731
Open
georgemunyoro wants to merge 1 commit into
Open
fix(net): force IPv4 and disable Happy Eyeballs in Node entrypoints#2731georgemunyoro wants to merge 1 commit into
georgemunyoro wants to merge 1 commit into
Conversation
PostHog's API and LLM gateway resolve to a many-address AWS ELB (~8 IPv4
+ ~8 IPv6). When IPv6 is unreachable (e.g. under Tailscale), Node's
default "Happy Eyeballs" (autoSelectFamily) races families with a short
per-attempt timeout and abandons each IPv4 attempt before the ELB connect
completes, timing out the whole connection — even though a plain IPv4
connect succeeds. This made the app unusable on Tailscale: the agent,
auth-proxy, MCP proxy and OAuth all make Node fetches that hung.
Set dns.setDefaultResultOrder("ipv4first") + net.setDefaultAutoSelectFamily(false)
in both Node entrypoints (workspace-server child and the Electron main
process). ipv4first alone is insufficient; the family racing must be off.
Generated-By: PostHog Code
Task-Id: 3b32c227-2ae9-4681-9617-6e6fa0cd0de9
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "fix(net): force IPv4 and disable Happy E..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Connections to
us.posthog.comfail when Tailscale is enabled. The root cause was traced to IPv6EHOSTUNREACHerrors during Nodefetch. PostHog's many-address ELB times out the connect when IPv6 is unreachable (e.g. via Tailscale), because Node's "Happy Eyeballs" family racing abandons each IPv4 attempt before it can complete. Settingipv4firstalone is not sufficient to resolve this.Reproduction
With Tailscale enabled, attempt to log in (against
us.posthog.com— not a locallocalhostPostHog, which is loopback and unaffected). The login fails because the main-process OAuth token call is a Nodefetchto PostHog's ELB, which times out. The same failure then affects the agent, auth-proxy and MCP proxy (all outbound Nodefetchfrom the workspace-server child), making the app effectively unusable.The underlying network failure can be reproduced directly:
Changes
apps/code/src/main/bootstrap.ts: Disable Happy Eyeballs vianet.setDefaultAutoSelectFamily(false)in the Electron main bootstrap, complementing the existingdns.setDefaultResultOrder(\"ipv4first\")call. Added an explanatory comment about whyipv4firstalone is insufficient.packages/workspace-server/src/serve.ts: Mirror the same network configuration (dns.setDefaultResultOrder(\"ipv4first\")+net.setDefaultAutoSelectFamily(false)) in the workspace-server entrypoint, since this child process makes all outbound HTTPS calls to PostHog and the gateway.How did you test this?
us.posthog.com(see Reproduction above) — login failed with IPv6EHOSTUNREACH/ETIMEDOUTerrors before the fix and succeeds after it.node -erepro fails with default settings and succeeds with--no-network-family-autoselection --dns-result-order=ipv4first.Automatic notifications
Created with PostHog Code