Skip to content

cli 0.8.0: doctor, IPv4/IPv6 fallback, same-service entry switch - #32

Merged
qiansc merged 1 commit into
mainfrom
feat/cli-network-family
Dec 1, 2026
Merged

qiansc merged 1 commit into
mainfrom
feat/cli-network-family

Conversation

@qiansc

@qiansc qiansc commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Background

A user's CLI timed out (UND_ERR_CONNECT_TIMEOUT) on one entry of a service while another entry worked. The error carried only a code, with no hint of which addresses or address family failed. On Node 18 the CLI does not fall back between IPv4 and IPv6, so a network that reaches a site over only one family waits 10 s and fails. The skill had no troubleshooting guidance for this, including for MCP clients.

Changes

CLI 0.8.0 (cli/):

  • sourcegraph doctor: checks DNS, a TCP connection to each IPv4/IPv6 address, HTTPS (/readyz) and the sign-in, then gives advice. Exit code 1 when the site cannot be reached or the sign-in failed; --json supported.
  • IPv4/IPv6 fallback: net.setDefaultAutoSelectFamily(true) at startup, so Node 18 behaves like Node 20+. The Node option --no-network-family-autoselection turns it off.
  • NETWORK_ERROR lists every address tried with its error and points to sourcegraph doctor.
  • Same-service entry switch: when a deployment profile gives a site a production_entry (the same service over another network path), and the site cannot be reached at all, the command uses that entry with the same token and prints a note. It switches only when the request never left the machine (name not resolved, connection refused/unreachable, connect timeout). The default profile has one site, so this is a no-op there.
  • engines.node is now >=18.18, the first version with family fallback.

Skill and README (generated from scripts/deployment): troubleshooting for NETWORK_ERROR and MCP timeouts. Run doctor first. MCP clients on Node 18 need NODE_OPTIONS=--network-family-autoselection. Don't edit the CLI launcher. Plugin version bumped to 0.8.0.

Risks

  • The entry switch happens only when the request was certainly not sent, so writes are never repeated. It is inactive for single-site deployments.
  • Family fallback is already the default on Node 20+, so nothing changes there. On Node 18, a healthy network still connects to the first address.
  • No server changes.

Backward compatibility

  • Commands, flags and output are unchanged. This adds the doctor command, plus a note on stderr when the CLI switches entries.
  • Node versions below 18.18 get an engines warning at install but still run, without family fallback.
  • Release: merge, then gh release create v0.8.0 publishes @c4a/sourcegraph 0.8.0.

Testing

  • bun test: 16 pass. New cli/src/network.test.ts covers:
    • Advice for one family down, everything down, a site not ready, and DNS failure.
    • The list of addresses tried.
    • End-to-end diagnosis of a local site, including the sign-in.
    • Switch tests, which run the bundled client under real Node:
      • A refused connection switches entries, sends the request once and keeps the token.
      • When both entries are down, the CLI reports one combined error.
      • A request the server received and then dropped is not switched.
  • Simulated dead IPv4 with live IPv6: search succeeds in under 1 s. With fallback off, it fails with a hint to run doctor.
  • Node 18 and 20 containers on an IPv4-only network: the CLI falls back to IPv4 automatically.
  • doctor against https://context4ai.org/sourcegraph from a machine without IPv6 reports the IPv6 address failing and IPv4 answering.
  • tsc: no new errors. node scripts/sync-deployment.mjs --check passes.

🤖 Generated with Claude Code

… same service

- sourcegraph doctor: DNS, a connection to each IPv4/IPv6 address, HTTPS and
  the sign-in, with advice.
- Turn on IPv4/IPv6 family fallback on Node 18 as Node 20+ does; NETWORK_ERROR
  lists the addresses tried. Node 18.18+.
- A deployment whose site has a production entry (same service, another
  network path) uses that entry when the site cannot be reached at all and the
  request never left this machine.
- Skill and README: troubleshooting for NETWORK_ERROR and MCP timeouts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qiansc
qiansc merged commit 666409f into main Dec 1, 2026
3 checks passed
@qiansc
qiansc deleted the feat/cli-network-family branch December 1, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant