You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash on startup when well-known credential endpoint is temporarily unavailable #22163
When a wellknown credential is configured but the associated endpoint (<url>/.well-known/opencode) is unavailable, opencode will fail to start with the following message:
$ opencode
{
"name": "UnknownError",
"data": {
"message": "Error: Unable to connect. Is the computer able to access the url?"
}
}
This was already reported in #10930 but closed due to inactivity, the issue still persists. A fix was attempted in #14522 but the PR is yet to be merged.
A similar thing happens when the JSON is malformed, then opencode also won't start, reporting:
In any case, I believe opencode should handle both of these cases gracefully, either ignoring unavailable/malformed endpoints or falling back to cached values.
Plugins
No response
OpenCode version
1.4.3
Steps to reproduce
Configure a local HTTP server that serves a minimal JSON payload, e.g. on http://127.0.0.1:8001/.well-known/opencode
An unreachable .well-known/opencode URL in auth.json crashes the entire application on startup. The config loader fetches every well-known URL without any error handling, so a single network failure (server down, DNS unreachable, VPN disconnected) kills the process before the TUI even renders.
It should start normally, loading the remote config from http://localhost:9999/.well-known/opencode.
4. Kill the server and restart opencode
Stop the npx serve process (Ctrl+C), then:
opencode
Result: Process crashes immediately with:
{"name":"UnknownError","data":{"message":"Error: Unable to connect. Is the computer able to access the url?"}}
Expected: Opencode should log a warning, skip the unreachable well-known config, and start normally.
5. Clean up
Remove the http://localhost:9999 entry from ~/.local/share/opencode/auth.json to restore normal startup.
Unit test reproduction
Add to test/config/config.test.ts (follows the same pattern as the existing wellknown tests):
test("config loads when wellknown URL is unreachable",async()=>{constoriginalFetch=globalThis.fetchglobalThis.fetch=mock((url: string|URL|Request)=>{consturlStr=urlinstanceofRequest ? url.url : urlinstanceofURL ? url.href : urlif(urlStr.includes(".well-known/opencode")){returnPromise.reject(newTypeError("Unable to connect. Is the computer able to access the url?"))}returnoriginalFetch(url)})asunknownastypeoffetchconstfakeAuth=Layer.mock(Auth.Service)({all: ()=>Effect.succeed({"http://localhost:9999": newAuth.WellKnown({type: "wellknown",key: "TEST_TOKEN",token: "test-token"}),}),})constlayer=Config.layer.pipe(Layer.provide(testFlock),Layer.provide(AppFileSystem.defaultLayer),Layer.provide(Env.defaultLayer),Layer.provide(fakeAuth),Layer.provide(emptyAccount),Layer.provideMerge(infra),Layer.provide(Npm.defaultLayer),)try{awaitprovideTmpdirInstance(()=>Config.Service.use((svc)=>Effect.gen(function*(){constconfig=yield*svc.get()expect(config).toBeDefined()}),),{git: true},).pipe(Effect.scoped,Effect.provide(layer),Effect.runPromise)}finally{globalThis.fetch=originalFetch}})
This test fails today with TypeError: Unable to connect. Is the computer able to access the url? -- the unhandled fetch rejection crashes config loading. It should pass after the fix is applied.
I can confirm that it is still important that OpenCode be usable offline (e.g. with on-device inference) even when my configuration includes well-known credentials for online-only providers. I run a community-specific provider that gets non-technical users onboard via the well-known route, but it undermines my story about how OpenCode is going to offer them resilience when it falls apart offline. Just having the associated config go ignored when unavailable is much preferred to failing to launch.
(I can imagine some scenarios where a remote config is somehow being used to lock down the general behavior of OpenCode, and letting it launch when the remote config is missing bypasses that lock-down. But who is actually using remote configs in that way? I'd rather a fail-open than fail-closed design for something like OpenCode that is user-centered rather than provider-centered.)
Activity
anthonyhull-ford commentedon Apr 27, 2026
Description
Unreachable well-known URL crashes app on startup
Bug
An unreachable
.well-known/opencodeURL inauth.jsoncrashes the entire application on startup. The config loader fetches every well-known URL without any error handling, so a single network failure (server down, DNS unreachable, VPN disconnected) kills the process before the TUI even renders.Root cause
packages/opencode/src/config/config.ts, insideloadInstanceState:opencode/packages/opencode/src/config/config.ts
Lines 489 to 509 in 61eabfc
The
fetch()call insideEffect.promise()has no try/catch. When Bun'sfetchcan't connect, it throws:This propagates as an unhandled rejection through the Effect runtime, crashing the config layer and therefore the entire startup.
The HTTP non-ok case does throw intentionally, but the network-level failure (DNS, connection refused, timeout) is completely unhandled.
Plugins
No response
OpenCode version
1.14.28
Steps to reproduce
Manual reproduction
1. Set up a local well-known server
Start the server:
2. Add a wellknown auth entry
Edit
~/.local/share/opencode/auth.jsonand add:{ "http://localhost:9999": { "type": "wellknown", "key": "MY_TOKEN", "token": "dummy" } }3. Verify opencode starts (server running)
It should start normally, loading the remote config from
http://localhost:9999/.well-known/opencode.4. Kill the server and restart opencode
Stop the
npx serveprocess (Ctrl+C), then:Result: Process crashes immediately with:
{"name":"UnknownError","data":{"message":"Error: Unable to connect. Is the computer able to access the url?"}}Expected: Opencode should log a warning, skip the unreachable well-known config, and start normally.
5. Clean up
Remove the
http://localhost:9999entry from~/.local/share/opencode/auth.jsonto restore normal startup.Unit test reproduction
Add to
test/config/config.test.ts(follows the same pattern as the existing wellknown tests):This test fails today with
TypeError: Unable to connect. Is the computer able to access the url?-- the unhandled fetch rejection crashes config loading. It should pass after the fix is applied.Screenshot and/or share link
Operating System
macOS Darwin 25.4.0
Terminal
iTerm2
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
rndmcnlly commentedon Sep 3, 2026
I can confirm that it is still important that OpenCode be usable offline (e.g. with on-device inference) even when my configuration includes well-known credentials for online-only providers. I run a community-specific provider that gets non-technical users onboard via the well-known route, but it undermines my story about how OpenCode is going to offer them resilience when it falls apart offline. Just having the associated config go ignored when unavailable is much preferred to failing to launch.
(I can imagine some scenarios where a remote config is somehow being used to lock down the general behavior of OpenCode, and letting it launch when the remote config is missing bypasses that lock-down. But who is actually using remote configs in that way? I'd rather a fail-open than fail-closed design for something like OpenCode that is user-centered rather than provider-centered.)