Skip to content

fix(ci): retry the pinned-npm-release check instead of racing the registry - #431

Merged
jpr5 merged 2 commits into
mainfrom
fix/npm-view-propagation-retry
Sep 11, 2026
Merged

jpr5 merged 2 commits into
mainfrom
fix/npm-view-propagation-retry

Conversation

@jpr5

@jpr5 jpr5 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

The defect

publish-pytest → Verify pinned npm release is published asked npm exactly once, so it raced the registry.

On the v1.41.0 release (run 34546620094):

  • publish published @copilotkit/[email protected] at 00:30:31
  • publish-pytest queried npm at 00:30:49 — 18 seconds later
  • npm answered E404 No match found for version 1.41.0
  • the step exited 1 and the whole Release run went red

The version existed. Re-running the failed job unchanged passed and published nothing. It will fail on roughly any release where propagation is slow, and it makes a completely successful release look broken.

The fix

Poll to a deadline instead of asking once. The guard is unchanged in purpose: it still exists to stop aimock-pytest shipping a pin to a version that was never published, and it still fails when the version is genuinely absent.

Ceiling: 300s, backoff 5s doubling to a 30s cap (~13 attempts). 300s is ~16x the observed 18s lag and past npm's replication tail, while staying small beside this job's own checkout/setup. A pin still missing after five minutes is a bad pin, not propagation, and must go red.

Transient vs. genuine. A per-version E404 conflates two failures, so a companion npm view <pkg> versions --json splits them:

companion query meaning action
the package itself 404s a bad pin — never propagation fail immediately, don't wait 5 minutes
the version list already carries the version published; the per-version 404 was a stale packument accept — the registry has already proven the fact
package exists, version absent genuinely ambiguous keep waiting; this is what the deadline is for
package query fails without a 404 registry unreachable transient, keep waiting

Every attempt logs its timestamp, the attempt number, and the npm error it got, so a future failure is diagnosable from the run log rather than a bare exit 1.

Red → green

The step's own run: body was extracted verbatim and executed.

RED (body on main @ 42eaaa2)

Genuinely missing version, real npm:

$ bash -e body.sh          # _version.py pinned to 99.99.99
npm error code E404
npm error 404 No match found for version 99.99.99
RED-1 exit=1 elapsed=0s

The race shape — a stub that 404s on the first 2 calls then succeeds:

RED-2 exit=1 elapsed=0s calls=1

One call, zero wait, red — where call 3 would have succeeded. That is the production failure exactly.

GREEN — the transient case now survives

attempt 1 (t+0s): @copilotkit/[email protected] not visible yet
  | npm error 404 No match found for version 1.41.0
  @copilotkit/aimock exists but does not list 1.41.0 yet - lag or a bad pin, still waiting
  retrying in 1s
attempt 2 (t+2s): @copilotkit/[email protected] not visible yet
  retrying in 1s
attempt 3: @copilotkit/[email protected] is published (1.41.0)
GREEN-A exit=0 elapsed=3s calls=3

GREEN — the half that actually matters: a genuinely missing version still FAILS

Full default 300s window, real npm, 99.99.99:

::error::@copilotkit/[email protected] is still not published after 13 attempts over 323s
(deadline 300s). aimock-pytest pins this version in
packages/aimock-pytest/src/aimock_pytest/_version.py; refusing to publish a pin to a
version npm does not have.

exit=1  elapsed=323s  attempts=13

And a pin to a package that does not exist fails fast, without burning the window:

attempt 1 (t+0s): @copilotkit/[email protected] not visible yet
::error::npm has no package named @copilotkit/aimock at all, so the pin 1.41.0 in
packages/aimock-pytest/src/aimock_pytest/_version.py is not a propagation delay.
Failing immediately.
exit=1 elapsed=0s

Coverage

src/__tests__/npm-publish-verify-workflow.test.ts follows the unreleased-check-workflow.test.ts idiom: it extracts the step's run: body, asserts the extraction is a literal substring of the workflow (so a paraphrasing extractor cannot pass), and executes it under bash against a stub npm. Four of the seven executed observations are negative controls, because a retry loop that swallowed a real bad pin would be strictly worse than the race it replaced.

Mutation-tested — the guard bites:

mutation result
deadline branch exit 1 → exit 0 (swallows a missing version) 3 tests fail
retry loop deleted, back to a single npm view 8 tests fail

Same pattern elsewhere?

Swept every workflow. The only other npm view is publish-release.yml:33, the build job's "Check if version is already published" — not the same pattern. It runs before publish, not read-after-write, and its failure means "not published yet", which is the path that proceeds to publish. Retrying there would be wrong. publish-commit.yml and publish-docker.yml do no read-after-write against a registry at all.

Worth noting separately, not fixed here: a transient 404 at line 33 would make npm publish run against an already-published version and fail with a conflict. That is a different race (stale-read-before-write) and out of scope for this PR.

Gates

gate exit
actionlint .github/workflows/publish-release.yml 0
prettier --check . 0
npx eslint . 0
pnpm typecheck 0
npx vitest run (190 files, 5850 tests) 0
npx commitlint --from origin/main --to HEAD 0

🤖 Generated with Claude Code

https://claude.ai/code/session_01AvkmhXVLqSSEW6FvPQHSu5

…istry

The publish-pytest job's "Verify pinned npm release is published" step asked
npm exactly once, so it raced propagation. On the v1.41.0 release (run
34546620094) the publish job landed 1.41.0 at 00:30:31 and this step asked for
it at 00:30:49 -- 18 seconds later -- and npm answered E404. The version
existed; re-running the job unchanged passed and published nothing. A release
gate that cries wolf is one people stop reading.

Poll to a deadline instead. 300s is ~16x the observed lag, past npm's
replication tail, and still small beside this job's own checkout/setup; a pin
still missing after five minutes is a bad pin, not propagation, and must go
red. Backoff is 5s doubling to a 30s cap, and every attempt is logged with the
npm error it got, so a future failure is diagnosable from the run log rather
than a bare exit 1.

A per-version E404 conflates two failures, so a companion `npm view <pkg>
versions --json` splits them:

  - the package itself 404s   -> a bad pin, never propagation: fail immediately
  - the version list has it   -> published; the per-version 404 was a stale
                                 packument, so stop waiting on a fact the
                                 registry has already proven
  - anything else             -> ambiguous, which is what the deadline is for

The guard still exists to stop aimock-pytest shipping a pin to a version that
was never published, and it still fails when the version is genuinely absent.
npm-publish-verify-workflow.test.ts executes the step's own `run:` body under
bash against a stub npm and pins that behaviourally -- the negative controls
(never-appears fails after the full window, missing package fails fast, an
unreachable registry is transient rather than a missing-package verdict) are
the half that matters, since a retry loop that swallowed a real bad pin would
be strictly worse than the race it replaced.
@pkg-pr-new

pkg-pr-new Bot commented Sep 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@431

commit: 20e0d88

@jpr5
jpr5 merged commit 2fe5631 into main Sep 11, 2026
32 checks passed
@jpr5
jpr5 deleted the fix/npm-view-propagation-retry branch September 11, 2026 08:09
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