Skip to content

fix(cli): omniroute update revalidates npm cache with --prefer-online (#4376) - #4486

Merged
diegosouzapw merged 2 commits into
release/v3.8.32from
fix/4376-update-prefer-online
Jun 21, 2026
Merged

diegosouzapw merged 2 commits into
release/v3.8.32from
fix/4376-update-prefer-online

Conversation

@diegosouzapw

Copy link
Copy Markdown
Owner

Closes #4376

Problem

@akbardwi pasted the exact output: on 3.8.30, omniroute update reported

Current version: 3.8.30
Latest version:  3.8.30
✔ You are running the latest version!

even though npm's latest dist-tag was already 3.8.31. So the updater told a user on an old build they were up to date.

Root cause

getLatestVersion() in bin/cli/commands/update.mjs ran npm view omniroute version without --prefer-online. npm view serves 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. getLatestVersion is 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:

  • getLatestVersion passes --prefer-online (+ still queries view omniroute version) — RED before the fix (function wasn't even exported).
  • returns null when npm is unavailable.

node --test → 2/2 pass; existing cli-update-global-paths-3295.test.ts still 2/2 (no regression). typecheck:core clean, ESLint 0 errors.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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;

@diegosouzapw
diegosouzapw merged commit 66909a8 into release/v3.8.32 Jun 21, 2026
4 checks passed
@diegosouzapw
diegosouzapw deleted the fix/4376-update-prefer-online branch June 21, 2026 12:33
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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