server: model catalog fetch times out on slow connections, blocking startup ~21s

未关闭
#67,104 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
electron, typescript

调研方向

Start with the server startup path exercised by opencode serve --service, then locate the model catalog request to the documented models.opencode.ai endpoint and inspect ~/.local/share/opencode/log/opencode.log. There are no file or test names in the issue, so find the existing fetch, timeout, configuration, and cache-related tests before changing behavior. Done means a slow catalog response can succeed or use cached data, and a failed refresh does not delay startup by the fetch timeout.

由索引模型根据 Issue 内容生成。

描述

area/providers platform/windows status/repro-simulated type/bug version/v2

Summary

On startup, OpenCode fetches the model catalog from https://models.opencode.ai/experimental/v2.0/api.json?type=chat,decision,image with a hardcoded ~10s timeout. On slow connections the response is ~11.6 MB and takes 16-27s, so the fetch always fails and startup is blocked for ~21s on every launch.

Environment

  • opencode version: v2.2.7
  • OS: Windows 10 22H2 (Microsoft Windows NT 10.0.19045.0), x64
  • Terminal: Desktop app (Electron + WebView2) - no terminal
  • Shell: C:\Windows\system32\cmd.exe
  • Install/channel: latest - desktop app ai.opencode.desktop, bundled CLI 2.2.7-x64
  • Active plugins: none

Reproduction

  1. Use a connection where models.opencode.ai downloads at ~450 KB/s.
  2. Start OpenCode (desktop app, or opencode serve --service).
  3. Watch ~/.local/share/opencode/log/opencode.log for role=server.

Expected Behavior

The catalog fetch either succeeds, is cached across launches, or is not on the critical startup path. A failed catalog fetch should not add ~20s to startup.

Actual Behavior

level=ERROR message="Failed to fetch models.dev"
cause="Cause([Fail(TimeoutError: Operation timed out after '10s')])"

The fetch is retried and startup is blocked for ~21s before MCP servers begin connecting.

Measured from this machine with the same URL:

attempt size time
1 11,641 KB 23.3s
2 11,641 KB 27.3s
3 11,641 KB 15.8s

The same URL fetched with Invoke-WebRequest and a 60s timeout returns HTTP 200 every time, so the endpoint is healthy - only the 10s client timeout is too short.

Additional Context

Startup timeline for a single run (from the log):

07:30:56  cli starting
07:30:57  location services booted (1.1s)
07:31:19  Failed to fetch models.dev   (+22s)
07:31:47  mcp connected                (+26s)

Failed to fetch models.dev appears 104 times in the log. Earlier occurrences also show transient DNS failures:

Transport error (GET https://models.opencode.ai/experimental/v2.0/api.json?type=chat,decision,image)
(cause: TypeError: getaddrinfo ENOTFOUND models.opencode.ai)

DNS resolves correctly now (Cloudflare 104.18.10.66 / 104.18.11.66), so the remaining failure is purely the timeout.

Requested fix: make the catalog timeout configurable (or raise it), and/or cache the last successful catalog so a failed refresh does not block startup.

Workaround tried: none available - no documented config field controls this timeout.

主要语言
TypeScript
星标
230k
派生
31.3k
平均合并
5 小时 32 分钟
30 天内合并 PR
453

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

anomalyco/opencode 的其他 Issue

查看 anomalyco/opencode 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。