Skip to content

fix(models): export setInterval handle so it can be cancelled#1349

Open
walker83 wants to merge 1 commit into
XiaomiMiMo:mainfrom
walker83:fix/models-setinterval-cleanup
Open

fix(models): export setInterval handle so it can be cancelled#1349
walker83 wants to merge 1 commit into
XiaomiMiMo:mainfrom
walker83:fix/models-setinterval-cleanup

Conversation

@walker83

Copy link
Copy Markdown

Summary

Store the models refresh interval timer ID in an exported variable so it can be cleared if needed.

Problem

setInterval(...).unref() was called without storing the handle. The timer ID was discarded, making it impossible to cancel the hourly refresh loop without killing the process. On module reload (HMR/development), a new interval is registered each time, accumulating timers.

Fix

  • Export modelsRefreshTimer variable
  • Store the interval handle
  • Clean up async wrapper (use void refresh() directly instead of async () => { await refresh() })

Changes

  • packages/opencode/src/provider/models.ts

Checklist

  • Timer can now be cleared externally
  • Backward compatible (optional export)

Store the models refresh interval ID in an exported module-level
variable (modelsRefreshTimer) so it can be cleared if needed.

Previously the setInterval handle was discarded, making it impossible
to stop the refresh loop without killing the process.
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.

1 participant