Skip to content

fix(opencode): retry npm publish and skip the main dist manifest - #159

Merged
quickbeard merged 1 commit into
mainfrom
publish-retry
Aug 2, 2026
Merged

quickbeard merged 1 commit into
mainfrom
publish-retry

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

Why

bun release for 1.18.4-5 died partway through with:

npm error code FETCH_ERROR
npm error network timeout at: https://registry.npmjs.org/codev-code-darwin-arm64

publish.ts fans all 13 packages out through Promise.all and every tarball is 40–60MB, so ~640MB of concurrent uploads regularly times one of them out and takes the whole release down with it. Nothing had been published at that point, so the release had to be redone from scratch.

What

Retry each npm publish up to 5 times with linear backoff (10s, 20s, 30s, 40s). After a failed attempt it re-checks the registry before retrying — a timed-out request can still have landed the version, and a blind retry would then fail with "cannot publish over existing version". After 5 attempts it throws naming the package.

Skip the main package directory when scanning dist manifests. Found while verifying the above. publish.ts globs dist/*/package.json to build optionalDependencies, and on a re-run that glob picks up the dist/opencode main-package directory generated by the previous run — so codev-code ends up depending on itself. A fresh build never hits it; release --skip-build (exactly the resume-a-failed-release path this PR exists to support) does. Fixed in the same commit for that reason.

Verification

  • bun typecheck in packages/opencode — clean.
  • Ran publish.ts against the already-published 1.18.4-5 dist/: all 13 packages hit the already published early return, nothing was published, and the regenerated dist/opencode/package.json has 12 optionalDependencies with no self-reference (13 with the self-reference before the fix).
  • The published codev-code@1.18.4-5 on npm is unaffected — it was published from a correct manifest and still lists 12 binaries.

DIVERGENCES.md row for packages/opencode/script/publish.ts updated in the same commit. No CHANGELOG.md entry — release tooling, no documented behavior change.

Note

Retry is a safety net, not a cure: the uploads still run concurrently, so the retries fire into the same saturated uplink and the first attempts will likely still fail. Serializing the uploads is what actually avoided timeouts when re-releasing 1.18.4-5 by hand. Worth a follow-up.

🤖 Generated with Claude Code

A release publishes 13 packages concurrently, each a 40-60MB tarball, and
the registry regularly times one of them out mid-upload with FETCH_ERROR
— aborting the whole release. Retry each publish up to 5 times with
linear backoff, and treat a version that appears on the registry after a
failed attempt as published, since a timed-out request can still land.

Resuming a release (`release --skip-build`) also scanned the main package
directory that a previous run generated under dist/, which put codev-code
into its own optionalDependencies. Skip that directory when collecting
the platform manifests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@quickbeard
quickbeard merged commit ffadbcb into main Aug 2, 2026
0 of 5 checks passed
@quickbeard
quickbeard deleted the publish-retry branch August 2, 2026 16:22
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