Repository navigation
fix(ci): retry the pinned-npm-release check instead of racing the registry - #431
Merged
Merged
Conversation
…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.
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
publishpublished@copilotkit/[email protected]at00:30:31publish-pytestqueried npm at00:30:49— 18 seconds laterE404 No match found for version 1.41.0The 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
E404conflates two failures, so a companionnpm view <pkg> versions --jsonsplits them: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:
The race shape — a stub that 404s on the first 2 calls then succeeds:
One call, zero wait, red — where call 3 would have succeeded. That is the production failure exactly.
GREEN — the transient case now survives
GREEN — the half that actually matters: a genuinely missing version still FAILS
Full default 300s window, real npm,
99.99.99:And a pin to a package that does not exist fails fast, without burning the window:
Coverage
src/__tests__/npm-publish-verify-workflow.test.tsfollows theunreleased-check-workflow.test.tsidiom: it extracts the step'srun:body, asserts the extraction is a literal substring of the workflow (so a paraphrasing extractor cannot pass), and executes it under bash against a stubnpm. 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:
exit 1→exit 0(swallows a missing version)npm viewSame pattern elsewhere?
Swept every workflow. The only other
npm viewispublish-release.yml:33, thebuildjob'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.ymlandpublish-docker.ymldo no read-after-write against a registry at all.Worth noting separately, not fixed here: a transient 404 at line 33 would make
npm publishrun 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
actionlint .github/workflows/publish-release.ymlprettier --check .npx eslint .pnpm typechecknpx vitest run(190 files, 5850 tests)npx commitlint --from origin/main --to HEAD🤖 Generated with Claude Code
https://claude.ai/code/session_01AvkmhXVLqSSEW6FvPQHSu5