Skip to content

fix(scripts): force IPv4 DNS on WSL2 to prevent bridge ETIMEDOUT#1066

Open
phanisaimunipalli wants to merge 1 commit intoNVIDIA:mainfrom
phanisaimunipalli:fix/wsl2-bridge-ipv6-etimedout
Open

fix(scripts): force IPv4 DNS on WSL2 to prevent bridge ETIMEDOUT#1066
phanisaimunipalli wants to merge 1 commit intoNVIDIA:mainfrom
phanisaimunipalli:fix/wsl2-bridge-ipv6-etimedout

Conversation

@phanisaimunipalli
Copy link
Copy Markdown

@phanisaimunipalli phanisaimunipalli commented Mar 29, 2026

Problem

On Windows WSL2 + Docker Desktop, nemoclaw start launches the Telegram bridge but the bridge process exits within seconds. nemoclaw status then shows it as stopped even though it was just started.

Root cause: WSL2 ships with broken IPv6 routing. Node.js resolves dual-stack DNS records and tries IPv6 addresses first. The IPv6 attempt returns ENETUNREACH and the IPv4 attempt times out with ETIMEDOUT:

AggregateError [ETIMEDOUT]:
  Error: connect ETIMEDOUT 149.154.166.110:443
  Error: connect ENETUNREACH 2001:67c:4e8:f004::9:443

This affects api.telegram.org and would affect gateway.discord.gg for any host-side bridge. curl is unaffected because it uses a CONNECT tunnel, not the Node.js http.Agent path.

Fix

Detect WSL2 via the standard environment variables (WSL_DISTRO_NAME, WSL_INTEROP) and the /proc/version marker. When WSL2 is detected, export NODE_OPTIONS=--dns-result-order=ipv4first before launching bridge processes so Node.js uses IPv4 DNS results exclusively.

This is a safe, additive change — it does not affect Linux, macOS, or cloud VM deployments. The --dns-result-order=ipv4first flag has been available since Node.js 17.

Testing

  • Non-WSL2 systems: unaffected — the if block does not execute
  • WSL2: NODE_OPTIONS is set before nohup node telegram-bridge.js — bridge connects to api.telegram.org via IPv4 immediately

Fixes #1065.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved DNS resolution handling for WSL2 environments to enhance connectivity and service reliability.

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 NVIDIA#1065.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1a4cad87-6292-4cbf-89f5-83ff0161187c

📥 Commits

Reviewing files that changed from the base of the PR and between eb4ba8c and c43e5a8.

📒 Files selected for processing (1)
  • scripts/start-services.sh

📝 Walkthrough

Walkthrough

A WSL2 detection mechanism was added to scripts/start-services.sh that conditionally sets the NODE_OPTIONS environment variable with --dns-result-order=ipv4first for Node.js processes before launching the telegram-bridge service, addressing DNS resolution timeout issues specific to Windows Subsystem for Linux 2.

Changes

Cohort / File(s) Summary
WSL2 DNS Configuration
scripts/start-services.sh
Added WSL2 detection block in do_start() that conditionally exports NODE_OPTIONS with IPv4-first DNS result ordering for telegram-bridge subprocess, includes informational logging.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through WSL2 land,
Where DNS tangled, DNS was grand,
But ipv4first, now swift and clear,
Telegram bridges draw ever near! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: forcing IPv4 DNS on WSL2 via NODE_OPTIONS to prevent bridge ETIMEDOUT errors.
Linked Issues check ✅ Passed The PR addresses the primary objective from issue #1065 by implementing WSL2 detection and setting NODE_OPTIONS to prefer IPv4, solving the ETIMEDOUT problem for the Telegram bridge on WSL2.
Out of Scope Changes check ✅ Passed All changes in scripts/start-services.sh are narrowly scoped to adding WSL2 detection and NODE_OPTIONS configuration, directly addressing issue #1065 without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@wscurran wscurran added Platform: Windows/WSL Support for Windows Subsystem for Linux fix labels Mar 30, 2026
@wscurran
Copy link
Copy Markdown
Contributor

✨ Thanks for submitting this PR with a detailed summary, it addresses a bug with IPv6 routing on WSL2 and proposes a fix to improve the compatibility of NemoClaw with this platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Platform: Windows/WSL Support for Windows Subsystem for Linux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram bridge fails on WSL2 (Windows) — ETIMEDOUT from host, no way to run inside sandbox

2 participants