Skip to content

Startup takes 10-30s, blocking network fetch of models.dev/api.json on every boot when cache is stale #42376

Closed as not planned

Description

@Vedant9500

Description

OpenCode blocks startup on a synchronous network fetch of the model registry (https://models.dev/api.json, ~3.6MB) whenever the local cache (~/.cache/opencode/models.json) is older than the 5-minute TTL. On connections where that host is slow/unstable, this adds 10-30 seconds to every launch before the TUI appears.

Measured on opencode 1.18.18, Linux, regular home connection (no proxy):

Condition Boot gap (config-load → interactive)
models cache fresh (<5 min) 0.7-0.8s
models cache stale, network slow 10-30s
fetch pointed at localhost mirror 0.74-0.77s

The fetch latency itself was measured up to 16.4s TTFB (plus occasional TLS errors) for models.dev/api.json. The call uses AbortSignal.timeout(10000) and Bun's native fetch(), which does not honor HTTP_PROXY/HTTPS_PROXY.

This is related to #9758: the existing OPENCODE_DISABLE_MODELS_FETCH flag is broken by design it only stops the background refresh timer, not the lazy Data() read path, and setting it bypasses the bundled snapshot so the model picker breaks. Not a usable escape hatch.

Request: make the boot-time registry fetch non-blocking (render TUI immediately from cache/snapshot, refresh in background), honor HTTP_PROXY/HTTPS_PROXY, and provide a working offline/skip_models_fetch config (or fix OPENCODE_DISABLE_MODELS_FETCH).

Plugins

none required, reproduced with an empty plugin array. (User's real config also has opencode-mem@2.22.2, @tarquinen/opencode-dcp@3.1.14, opencode-pty@0.3.6, ./plugins/caveman/plugin.js; these add ~2s total and are not the cause.)

OpenCode version

1.18.18

Steps to reproduce

  1. Install opencode 1.18.18 (no plugins needed).
  2. Age the cache: touch -d "10 minutes ago" ~/.cache/opencode/models.json (or wait >5 min after last run).
  3. Launch: script -qc "opencode" /dev/null (or a normal terminal).
  4. Time from invocation until the TUI is interactive; compare to a run where the cache was just refreshed.

Screenshot and/or share link

No response

Operating System

Linux (Arch)

Terminal

Alacritty

Activity

  1. github-actions commented on Aug 13, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. opencode-agent commented on Aug 14, 2026

    @opencode-agent
    Contributor

    I can’t reproduce the claimed blocking path from the current implementation or the exact v1.18.18 source.

    ModelsDev.populate() returns an existing disk cache regardless of its age, then falls back to the bundled snapshot. Cache staleness is only checked by refresh(), which runs in a forked background fiber. OPENCODE_DISABLE_MODELS_FETCH also prevents that refresh. Therefore, aging models.json past five minutes does not make startup synchronously wait for the catalog fetch.

    There may be a separate source of startup latency in the reported environment, but the proposed root cause and reproduction do not match the released code. Closing as cannot reproduce.

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

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