Skip to content

fix(bun): use direct npm registry fetch for plugin @latest update checks#16609

Open
conversun wants to merge 1 commit intoanomalyco:devfrom
conversun:fix/plugin-latest-cache-invalidation
Open

fix(bun): use direct npm registry fetch for plugin @latest update checks#16609
conversun wants to merge 1 commit intoanomalyco:devfrom
conversun:fix/plugin-latest-cache-invalidation

Conversation

@conversun
Copy link

@conversun conversun commented Mar 8, 2026

Issue for this PR

Closes #16608

Type of change

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

What does this PR do?

Plugins configured with @latest never auto-update because the isOutdated check in registry.ts uses bun info (subprocess) which returns stale data from bun's registry cache. Even when it works, bun add also uses cached packages since --no-cache is only passed behind proxies/CI.

This PR makes two targeted changes:

  1. registry.ts: Replaces bun info <pkg> version subprocess with a direct fetch() to registry.npmjs.org. This bypasses bun's registry cache entirely, and fetch() natively respects HTTP_PROXY/HTTPS_PROXY env vars — making it more reliable behind proxies where the subprocess often fails silently (causing isOutdated to return false).

  2. index.ts: Adds version === "latest" to the --no-cache condition for bun add, so when an update IS detected, bun actually downloads the new package instead of serving it from its local package cache.

  3. config.ts: Updated call site to match the simplified isOutdated signature (removed unused cwd param that was only needed for bun info).

How did you verify your code works?

  • Confirmed the npm registry HTTP endpoint returns correct latest versions for scoped and unscoped packages (oh-my-opencode, @opencode-ai/plugin)
  • Verified existing unit tests and e2e tests pass (11/12 checks passed, typecheck initially failed due to a missed call site in config.ts which has been fixed)
  • The fetch() approach uses a 10s AbortSignal.timeout and falls back gracefully (returns false = "not outdated") if the registry is unreachable

Screenshots / recordings

Not a UI change.

Checklist

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

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 8, 2026
Replace `bun info` subprocess (subject to bun's stale registry cache)
with a direct HTTP fetch to registry.npmjs.org for version checks.

Also always pass `--no-cache` to `bun add` when version is 'latest'
to ensure fresh package data is fetched during plugin updates.

Fixes anomalyco#16608
@conversun conversun force-pushed the fix/plugin-latest-cache-invalidation branch from 3ef71eb to 0ca3d60 Compare March 8, 2026 14:57
@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

Plugins configured with @latest never auto-update: bun registry cache + stale isOutdated check

1 participant