Skip to content

fix(provider): await models.dev refresh before computing provider state - #15609

Closed
Br1an67 wants to merge 1 commit into
anomalyco:devfrom
Br1an67:fix/issue-8587-model-id-format
Closed

Br1an67 wants to merge 1 commit into
anomalyco:devfrom
Br1an67:fix/issue-8587-model-id-format

Conversation

@Br1an67

@Br1an67 Br1an67 commented Mar 1, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #8587

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

ModelsDev.refresh() fires at module load (fire-and-forget) but Provider.state() can resolve from the bundled snapshot before the refresh completes. When a model exists in live models.dev but not in the snapshot, getModel() throws ProviderModelNotFoundError.

This fix tracks the initial refresh promise via startRefresh() and awaits it in Provider.state() initialization through ensureFresh(). If the refresh fails or was never started (e.g. OPENCODE_DISABLE_MODELS_FETCH), the await is a no-op and falls through to the snapshot as before.

How did you verify your code works?

  • Traced the race: Data() resolves from snapshot → state() computes → refresh() completes and resets Data too late
  • Confirmed remeda.mergeDeep preserves shared references (nested objects not in the merge source keep the same ref), so Data.reset() after state() has resolved doesn't help
  • Ran provider and tool tests — no regressions (pre-existing bash permission failures unrelated)

Screenshots / recordings

N/A — backend fix

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The provider state initialization could use a stale bundled snapshot
when the background models.dev refresh hadn't completed yet. This caused
ProviderModelNotFoundError for models that exist in models.dev but not
in the snapshot.

Track the initial refresh promise via startRefresh() and await it in
ensureFresh() before computing provider state. If the refresh fails or
was never started, ensureFresh() is a no-op.
@Br1an67

Br1an67 commented Mar 10, 2026

Copy link
Copy Markdown
Author

Hi — just a gentle bump on this. Happy to make any changes if needed!

@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode Zen GPT-5.2 Codex install model fails (ProviderModelNotFoundError)

1 participant