Skip to content

ci: wait out npm's registry propagation before installing the published SDK - #42

Merged
AshDevFr merged 1 commit into
mainfrom
fix/npm-registry-propagation
Aug 22, 2026
Merged

ci: wait out npm's registry propagation before installing the published SDK#42
AshDevFr merged 1 commit into
mainfrom
fix/npm-registry-propagation

Conversation

@AshDevFr

Copy link
Copy Markdown
Owner

Summary

publish-plugins intermittently fails with "no matching version" for @ashdev/codex-plugin-sdk, and a manual re-run fixes it.

The cause is a race, not flakiness in the usual sense. The job rewrites each plugin's SDK dependency from file:../sdk-typescript to the version publish-sdk has just pushed, then does rm -rf node_modules package-lock.json && npm install. That install must resolve the SDK from the registry, seconds after publish. npm's registry is eventually consistent across CDN edges, so the version is not yet visible everywhere and the install fails.

The fix

Two guards, because either alone leaves a hole:

  1. Poll npm view until the version is visible, up to five minutes, before installing.
  2. Retry npm install up to five times anyway. npm view and npm install do not necessarily hit the same CDN edge, so the poll succeeding does not prove the install will resolve. --prefer-online revalidates rather than trusting a 404 the failed attempt cached.

The version is exported through GITHUB_ENV so the poll can see what the rewrite step computed.

What this does not do

It waits the race out rather than removing it. The alternative is to build against the local file: SDK and rewrite the manifest only at publish time — the esbuild bundle is byte-identical either way, so the registry would never be consulted during the build and the race could not occur. That was the stronger option and it was considered; it restructures a publish path that cannot be exercised outside a real release, which is a poor trade against a job that already works on retry.

Worth revisiting if the retries themselves start failing.

Verification

The poll predicate was validated against the live registry rather than assumed:

npm view @ashdev/codex-plugin-sdk@2.1.0  version  ->  "2.1.0"   (non-empty: loop exits)
npm view @ashdev/codex-plugin-sdk@99.0.0 version  ->  ""        (empty: loop keeps waiting)

The workflow YAML parses and the step order is correct.

This cannot be verified by CIpublish-plugins only runs on a release, so the first real exercise is the next tag.

…ed SDK

`publish-plugins` rewrites each plugin's SDK dependency from `file:` to the
version `publish-sdk` has just pushed, then reinstalls. That install has to
resolve the SDK from the registry seconds after it was published, and npm's
registry is eventually consistent across CDN edges, so it intermittently fails
with "no matching version" and a manual re-run fixes it.

Adds two guards, because one is not enough:

- Poll `npm view` until the version is visible, up to five minutes, before
  attempting the install.
- Retry `npm install` up to five times anyway. `npm view` and `npm install` do
  not necessarily hit the same CDN edge, so the poll succeeding does not prove
  the install will resolve. `--prefer-online` revalidates rather than trusting a
  404 cached by the failed attempt.

The version is exported through GITHUB_ENV so the poll can see what the rewrite
step computed.

This does not remove the race, it waits it out. Building against the local
`file:` SDK and rewriting the manifest only at publish time would remove it
outright, since the bundle is identical either way, but that restructures a
publish path that is awkward to test — this is the change that can be reasoned
about when a release is half out.

Not verifiable in CI: `publish-plugins` only runs on a release.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying codex with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3ebfbd9
Status: ✅  Deploy successful!
Preview URL: https://679e680f.codex-asm.pages.dev
Branch Preview URL: https://fix-npm-registry-propagation.codex-asm.pages.dev

View logs

@AshDevFr
AshDevFr merged commit 7e2eab8 into main Aug 22, 2026
23 checks passed
@AshDevFr
AshDevFr deleted the fix/npm-registry-propagation branch August 22, 2026 21:01
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