Skip to content

fix(opencode): drop stale tarballs before packing - #250

Merged
quickbeard merged 1 commit into
mainfrom
fix/stale-tarball-pack
Aug 17, 2026
Merged

quickbeard merged 1 commit into
mainfrom
fix/stale-tarball-pack

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

What

bun pm pack writes its tarball into the directory it packs. A second pack in the same dist dir therefore sees the previous run's .tgz as package content and bundles it — so every release --skip-build retry, the documented way to resume a failed publish, doubled every platform package:

package/package.json
package/bin/codev                              135 MB
package/codev-code-darwin-x64-1.18.4-8.tgz      43 MB   <- junk

Deleting stale *.tgz before packing takes each platform package from ~112MB (3 files) back to ~55MB (2 files).

Why it matters beyond size

This is what made the concurrent uploads in this script start timing out. 13 packages at twice their expected size saturate a laptop uplink long enough for npm to give up mid-upload (FETCH_ERROR), and the retry loop then re-packs even bigger tarballs each round. The existing ATTEMPTS = 5 loop was sized for the 40-60MB packages noted at the top of the file — this restores that assumption.

Scope

  • packages/opencode/script/publish.ts — delete stale *.tgz before bun pm pack, via Bun.Glob + Bun.file().delete() (Bun's shell errors on an unmatched glob, so rm -f *.tgz breaks on the main package dir, which has no tarball).
  • DIVERGENCES.md — row 110 extended; publish.ts is an upstream file and the row already covers the retry loop this interacts with.
  • CHANGELOG.md — ### Install entry under Unreleased; halving install download is user-facing.

Status of 1.18.4-8

Already published. 9 of the 13 packages went up hand-repacked and clean; codev-code-darwin-arm64, codev-code-darwin-x64, and codev-code-darwin-x64-baseline were published before this was found and keep the nested copy — npm burns a version permanently on unpublish, so they stay as-is and self-correct next release. 1.18.4-7 has the same flaw, so this is not a regression.

Test plan

  • bun typecheck from packages/opencode passes.
  • Verified on dist/opencode-linux-x64: repack took the tarball 112M -> 55M, contents package/package.json + package/bin/codev only.
  • Verified the empty-dir case (no .tgz present) does not throw — that is the main package dir on every run.
  • npm install codev-code@1.18.4-8 in a scratch dir resolves and runs: codev --version -> 1.18.4-8.

🤖 Generated with Claude Code

`bun pm pack` writes its tarball into the directory it packs, so a second
pack in the same dist dir bundles the previous run's tarball as package
content. Any `release --skip-build` retry — the documented way to resume a
failed publish — therefore doubled every platform package, ~55MB to ~112MB.

That is also why the concurrent uploads in this script started timing out:
13 packages at twice the expected size saturate the uplink long enough for
npm to give up mid-upload (`FETCH_ERROR`), which the retry loop then makes
worse by re-packing even bigger tarballs.

Delete any stale `*.tgz` before packing. Shipped in 1.18.4-8 for 9 of the
13 packages, hand-repacked; the three darwin ones went up before this was
found and keep the nested copy at that version.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@quickbeard
quickbeard merged commit 29dcde0 into main Aug 17, 2026
0 of 5 checks passed
@quickbeard
quickbeard deleted the fix/stale-tarball-pack branch August 17, 2026 02:47
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