fix(cli): omniroute update revalidates npm cache with --prefer-online (#4376) - #4486
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Code Review
This pull request updates the getLatestVersion function in bin/cli/commands/update.mjs to include the --prefer-online flag when querying npm, preventing stale cached versions from being returned. It also exports the function and allows dependency injection of the execution function for testing, with corresponding unit tests added in tests/unit/cli-update-prefer-online-4376.test.ts. The reviewer noted a potential TypeScript compilation error in the new test file where capturedArgs is initialized to null without an explicit type annotation, which would fail under strict null checks when an object is later assigned to it.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| // without `--prefer-online`, so npm served a stale value from its HTTP cache. | ||
| // The fix forces npm to revalidate the cache against the registry. | ||
| test("getLatestVersion passes --prefer-online to bypass the stale npm cache (#4376)", async () => { | ||
| let capturedArgs = null; |
There was a problem hiding this comment.
Under strict TypeScript configuration (strictNullChecks: true), initializing capturedArgs to null without an explicit type annotation infers its type as null. This will cause a compilation error when assigning an object to it on line 14. Specifying an explicit union type resolves this issue.
let capturedArgs: { cmd: string; args: string[] } | null = null;…pdate-prefer-online
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Closes #4376
Problem
@akbardwi pasted the exact output: on
3.8.30,omniroute updatereportedeven though npm's
latestdist-tag was already3.8.31. So the updater told a user on an old build they were up to date.Root cause
getLatestVersion()inbin/cli/commands/update.mjsrannpm view omniroute versionwithout--prefer-online.npm viewserves from npm's HTTP cache by default, so a stale cached entry (3.8.30) was returned instead of the live registry value (3.8.31).Fix
Pass
--prefer-online, which forces npm to revalidate its cache against the registry before answering.getLatestVersionis now exported and takes an injectable exec runner so the npm args are unit-testable.Tests (TDD, RED→GREEN)
tests/unit/cli-update-prefer-online-4376.test.ts:getLatestVersionpasses--prefer-online(+ still queriesview omniroute version) — RED before the fix (function wasn't even exported).nullwhen npm is unavailable.node --test→ 2/2 pass; existingcli-update-global-paths-3295.test.tsstill 2/2 (no regression).typecheck:coreclean, ESLint 0 errors.