Skip to content

opencode crashes on boot when models.dev is unreachable with no cache #35713

Description

@luiscga

Description

If models.dev is unreachable and there's no local cache yet (fresh install, or cache cleared), opencode crashes on boot instead of degrading gracefully. The server dies mid-bootstrap and the TUI just shows:

Error: Unexpected server error. Check server logs for details.

and exits. Nothing in the UI, no toast, no partial startup - it just closes.

Log on the server side stops dead right after the fetch fails, nothing after it:

timestamp=2026-07-07T11:32:22.844Z level=INFO run=c20bd434 message=init
timestamp=2026-07-07T11:32:22.9xxZ level=ERROR run=c20bd434 message="Failed to fetch models.dev" cause="Cause([Fail(HttpClientError: Transport error (GET .../api.json) (cause: Error: Unable to connect. Is the computer able to access the url?))])"

(process exits here, no further log lines)

Looks like populate() in packages/core/src/models-dev.ts pipes the fetch through Effect.orDie, so a plain network failure turns into an unrecoverable defect that kills the whole instance bootstrap rather than just failing to load the catalog.

There's a second related spot: currentModel() in packages/opencode/src/session/prompt.ts also does provider.defaultModel().pipe(Effect.orDie), so if you already have a project with a saved model selection and the catalog ends up empty for the same reason, sending a prompt dies the same way instead of surfacing a normal error.

Plugins

None

OpenCode version

1.17.14

Steps to reproduce

  1. Make sure there's no cached catalog (rm ~/.cache/opencode/models.json or use a fresh XDG_CACHE_HOME)
  2. Point the fetch at something unreachable, e.g. OPENCODE_MODELS_URL=http://127.0.0.1:1
  3. Start opencode in a project directory
  4. It boots, then dies within a couple seconds with the error above

Screenshot and/or share link

No response

Operating System

macOS

Terminal

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions