Repository navigation
fix(version): keep the npm version check from blocking commits when offline - #597
Merged
di-sukharev merged 1 commit intoNov 11, 2026
Conversation
Introduce a disk-based cache and a network timeout for the npm registry version check to avoid blocking commit generation when offline or using a local provider like Ollama (see di-sukharev#347). - Add `resolveLatestVersion` that wraps `getOpenCommitLatestVersion` with a file-based cache stored in `~/.opencommit-version.json` - Successful checks are cached for 24 hours; failed checks are cached for 30 minutes to avoid repeated timeouts on every run - When offline, fall back to the last known latest version from the cache so the update prompt still works after a prior check - Add a 2-second `AbortSignal` timeout to the fetch call so a hanging registry never blocks the CLI startup path - Invalidate the cache when the installed version changes - Update `checkIsLatestVersion` to use `resolveLatestVersion` - Add comprehensive unit tests covering cache hits, misses, expiry, fallback, version change and corrupt cache scenarios
di-sukharev
approved these changes
Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #347. Likely also addresses #311, which was noted as the same symptom.
Problem
Every normal
ocorun awaits the npm registry version check beforegenerating a commit message. The request had no timeout, so with no
internet (for example when using a local provider such as Ollama) the
CLI could hang for a long time before doing any work.
Changes
src/version.ts, so the check is strictly best-effort.~/.opencommit-version.json, next to the existing~/.opencommit-models.json:the timeout at most once per window;
update notice still works offline.
does not leave a stale update notice.
checkIsLatestVersionnow uses the cached lookup.This follows the implementation suggested in the issue thread and
builds on #573.
Tests
test/unit/version.test.tsadds a regression test for a registry thatnever responds, plus cache tests: hit, expiry, failed-check window,
offline fallback, installed-version change, and a corrupt cache file.
npm run test:unit,npm run lintandnpm run format:checkpasslocally.