Summary
Remote MCP servers get stuck in failed when the machine wakes from sleep. OpenCode reconnects right after wake, before Windows DNS is back. Every attempt fails with getaddrinfo ENOTFOUND, OpenCode stops retrying after ~1.3 seconds, and the server stays failed until I reconnect it by hand.
Environment
- opencode version: 2.2.5
- OS: Windows NT 10.0.26300 (win32 x64), Modern Standby
- Terminal: Unavailable: terminal environment variables are not set
- Shell: cmd.exe
- Install/channel: latest
- Active plugins:
github:PirisLabs/opencode-provider#13d02816762a764dccdba5fbbdb41a731762eb3f
Reproduction
- Configure a remote MCP server, for example
notion with type: remote and url: https://mcp.notion.com/mcp, OAuth. opencode mcp list shows connected.
- Put the machine to sleep with the TUI and the background service running.
- Wake it with the power button.
- The TUI reconnects. The service tears down the old MCP session and opens a new one.
- Windows Wi-Fi and DNS need a few seconds after wake. The connect attempts run before DNS is back and fail with
getaddrinfo ENOTFOUND mcp.notion.com.
opencode mcp list shows failed. It stays that way.
Expected Behavior
A short DNS failure after wake should not fail the server for good. Retry with backoff for 30-60s, or retry a failed server every few minutes, so it recovers by itself.
Actual Behavior
3 attempts over ~1.3 seconds, then the server goes to failed and nothing retries it. It stayed failed for 28+ minutes, until I reconnected it by hand. DNS was back within a minute of wake.
Log excerpt (UTC, trimmed):
18:01:19.570Z INFO location services evicted
18:01:19.984Z WARN mcp http request failed method=DELETE durationMs=253
errors=[{"type":"TypeError","message":"getaddrinfo ENOTFOUND mcp.notion.com","code":"ENOTFOUND","errno":4}]
18:01:20.009Z WARN failed to terminate MCP session server=notion error="getaddrinfo ENOTFOUND mcp.notion.com"
18:01:25.374Z WARN mcp http request failed method=POST durationMs=26 (same ENOTFOUND)
18:01:25.376Z WARN retrying MCP connect server=notion
18:01:25.630Z WARN mcp http request failed method=POST durationMs=1 (same ENOTFOUND)
18:01:25.631Z WARN retrying MCP connect server=notion
18:01:26.649Z WARN mcp http request failed method=POST durationMs=4 (same ENOTFOUND)
18:01:26.651Z WARN mcp connect failed server=notion status.status=failed status.error="getaddrinfo ENOTFOUND mcp.notion.com"
Retry gaps: 0s, +0.26s, +1.02s. Nothing after that.
Windows event log confirms the wake at the same moment:
Kernel-Power 42 01:34:32Z system entering sleep (button or lid)
Kernel-General 1 18:01:19.5Z system time changed from 01:34:37Z to 18:01:19.5Z, delta 59,202,477 ms (~16.4h)
Power-Troubleshooter 1 18:01:19.5Z returned from low power state, wake reason: power button
I checked DNS a minute later: Resolve-DnsName and Node dns.lookup both resolve the host, and a plain curl POST to the endpoint returns HTTP 401 in 0.22s.
Additional Context
- Config, OAuth credential, and endpoint are all fine. The token refresh worked on the manual reconnect and the server connected with 78 tools.
- Workarounds:
/mcps in the TUI then connect, POST /api/experimental/mcp/{server}/connect with a location[directory] query param, or opencode service restart.
- Re-saving
opencode.json does not reconnect a failed server. The config.updated event fires but there is no new connect attempt.
- No retry or backoff config for MCP connections in 2.2.5, only
startup/catalog/execution timeouts.
- Not just sleep/wake. Any short DNS outage hits this. On Oct 22 this machine had ~1h with no DNS and every network call in the log failed the same way. MCP is the one that never recovers, because nothing retries it.