From c43e5a89c930338d6e5d20137247e45e70458b23 Mon Sep 17 00:00:00 2001 From: phanisaimunipalli Date: Sun, 29 Mar 2026 11:16:09 -0700 Subject: [PATCH] fix(scripts): force IPv4 DNS on WSL2 to prevent bridge ETIMEDOUT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On WSL2 + Docker Desktop, Node.js resolves dual-stack DNS records and tries IPv6 first. WSL2's IPv6 routing is broken, so the IPv6 attempt returns ENETUNREACH and the IPv4 attempt times out with ETIMEDOUT. This causes the Telegram bridge (and any future host-side bridge) to fail immediately after start — the process exits and the PID file becomes stale. Detect WSL2 via the standard environment variables (WSL_DISTRO_NAME, WSL_INTEROP) and the /proc/version marker, then export NODE_OPTIONS=--dns-result-order=ipv4first before launching bridge processes. This makes Node.js use IPv4 results exclusively for DNS lookups, which resolves the ETIMEDOUT without affecting non-WSL2 deployments. Fixes #1065. Co-Authored-By: Claude Sonnet 4.6 --- scripts/start-services.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/start-services.sh b/scripts/start-services.sh index 303caf696..797052049 100755 --- a/scripts/start-services.sh +++ b/scripts/start-services.sh @@ -132,6 +132,15 @@ do_start() { command -v node >/dev/null || fail "node not found. Install Node.js first." + # WSL2 ships with broken IPv6 routing. Node.js resolves dual-stack DNS results + # and tries IPv6 first (ENETUNREACH) then IPv4 (ETIMEDOUT), causing bridge + # connections to api.telegram.org and gateway.discord.gg to fail from the host. + # Force IPv4-first DNS result ordering for all bridge Node.js processes. + if [ -n "${WSL_DISTRO_NAME:-}" ] || [ -n "${WSL_INTEROP:-}" ] || grep -qi microsoft /proc/version 2>/dev/null; then + export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--dns-result-order=ipv4first" + info "WSL2 detected — setting --dns-result-order=ipv4first for Node.js bridge processes" + fi + # Verify sandbox is running if command -v openshell >/dev/null 2>&1; then if ! openshell sandbox list 2>&1 | grep -q "Ready"; then