Skip to content

ci(npm): tolerate already-published race in npm publish (closes #70)#72

Merged
BunsDev merged 1 commit into
mainfrom
fix/70-npm-publish-race
Jun 11, 2026
Merged

ci(npm): tolerate already-published race in npm publish (closes #70)#72
BunsDev merged 1 commit into
mainfrom
fix/70-npm-publish-race

Conversation

@BunsDev

@BunsDev BunsDev commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the spurious red X on releases (#70, observed on v0.0.25).

Corrected diagnosis: the concurrency group proposed as option 2 in the issue already exists and works — the runs do serialize. The actual gap is that the second run's pre-publish npm view guard races npm's read-after-write propagation: the version published seconds earlier isn't visible yet, so the guard passes and npm publish exits with E403 "cannot publish over the previously published versions".

Fix (issue option 1): capture the publish output; if it fails with the already-published 403, treat it as success (the version is on the registry — that's the goal state). A 3×5s npm view re-poll backstops any other transient visibility lag. Genuine failures (auth, network, validation) still fail the job.

Test plan

  • YAML validated.
  • Publish-loop control flow exercised with a mocked npm for all three paths: normal publish → success; 403 race → success with explanatory log line; hard failure (E401) → job fails.
  • Real-world verification happens on the next release cut — the workflow_run-triggered run should now end green.

Closes #70.

🤖 Generated with Claude Code

Closes #70.

The workflow's two triggers (release.yml explicit dispatch +
workflow_run on Release completion) fire back-to-back per release. The
static concurrency group already serializes the runs, but the second
run's pre-publish `npm view` guard races npm's read-after-write
propagation: a version published seconds earlier may not be visible
yet, so the guard passes and the publish dies with E403 "cannot publish
over the previously published versions" — a spurious red X on an
otherwise successful release (observed on v0.0.25).

Treat that 403 as the success it is: capture the publish log, match the
already-published error, and exit 0. As a last resort, re-poll
`npm view` (3 x 5s) before declaring real failure. Genuine publish
failures (auth, network, validation) still fail the job.

Control flow verified with a mocked npm for all three paths
(publish-ok, 403-race, hard-failure).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 11, 2026 04:22
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Jun 11, 2026 4:22am

@BunsDev BunsDev merged commit 82a3c08 into main Jun 11, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the npm publish GitHub Actions workflow to avoid spurious failures when two serialized publish runs still race npm registry read-after-write propagation (the version is published but npm view can lag briefly), closing #70.

Changes:

  • Capture npm publish output and treat the specific “already published” E403 failure as a successful end state.
  • Add a short (3×5s) npm view re-poll backstop before failing on other publish errors.
  • Refactor publish flags into a publish_args array to avoid duplication.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +279 to 284
publish_log="$(mktemp)"
if (cd npm && npm publish "${publish_args[@]}") 2>&1 | tee "$publish_log"; then
echo "${package_name}@${VERSION} published."
elif grep -q "cannot publish over the previously published versions" "$publish_log"; then
echo "${package_name}@${VERSION} was already published by a concurrent run; treating as success."
else
@BunsDev BunsDev deleted the fix/70-npm-publish-race branch June 11, 2026 05:54
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.

npm-publish: redundant-trigger race produces spurious red X on releases

2 participants