From 050a2893dbae616f3edead9939d806afdfc1b359 Mon Sep 17 00:00:00 2001 From: "Ralph Sto. Domingo" Date: Mon, 23 Nov 2026 13:53:23 +0800 Subject: [PATCH] fix: warm the Solid plugin before the release bundle and retry a failed build once Babel's lazy requires on the JS thread raced Bun 1.3.14's unlocked resolver cache inside `Bun.build`, so a target could read `@babel/traverse` as a file (EISDIR). Warm it first; `release.yml` retries a failed build once. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VEmKQv6E2XpAgL5eJE8RYi --- .github/workflows/release.yml | 16 +++++++++++++++- packages/opencode/script/build.ts | 25 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a4a52e4dc2..27cd7da004 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -89,7 +89,21 @@ jobs: run: bun install - name: Build ${{ matrix.name }} - run: bun run packages/opencode/script/build.ts --target-index=${{ matrix.index }} + # altimate_change start — retry a failed build once, so one flaky target can't hold up + # the release (see the Solid plugin warm-up in build.ts for the flake we know of). The + # retry is a new `bun run`: Bun keeps a misread resolver entry for the life of the + # process. The warning keeps the first failure visible on the run summary. + run: | + for attempt in 1 2; do + if bun run packages/opencode/script/build.ts --target-index=${{ matrix.index }}; then + exit 0 + fi + if [ "$attempt" = 1 ]; then + echo "::warning::Build (${{ matrix.name }}) failed on attempt 1; retrying once in a fresh process" + fi + done + exit 1 + # altimate_change end env: OPENCODE_VERSION: ${{ github.ref_name }} # altimate_change — derive channel from the tag: a prerelease tag (e.g. v0.9.0-beta.1) diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts index b253306912..e591f77314 100755 --- a/packages/opencode/script/build.ts +++ b/packages/opencode/script/build.ts @@ -2,6 +2,9 @@ import { $ } from "bun" import fs from "fs" +// altimate_change start — tmpdir for the Solid plugin warm-up build below +import os from "os" +// altimate_change end import path from "path" import { fileURLToPath } from "url" import { createRequire } from "node:module" @@ -500,6 +503,28 @@ function locatePlatformPackageDir(pkgName: string): string { const pkgJsonPath = altimateCoreLoaderRequire.resolve(`${pkgName}/package.json`) return fs.realpathSync(path.dirname(pkgJsonPath)) } + +// altimate_change start — warm the Solid plugin before the real bundles. +// The plugin's .tsx loader runs Babel on the JS thread, and Babel requires most of its +// dependencies lazily on its first transform. Inside `Bun.build` those lookups race the +// bundle thread, which resolves the same symlinked `node_modules/.bun` entries for the +// copy of @babel/core this binary embeds (via @opentui/solid/runtime-plugin-support). +// Bun 1.3.14's resolver fills each entry's kind without a lock, so either side can read a +// package directory as a file: `EISDIR reading ".../node_modules/@babel/traverse"`, on a +// random target. One throwaway transform here, in a build that resolves nothing, does +// those lookups first. Bun 1.4 locks that lookup; this block can go once we build on it. +{ + const warmDir = fs.mkdtempSync(path.join(os.tmpdir(), "altimate-solid-warm-")) + try { + const warmEntry = path.join(warmDir, "warm.tsx") + fs.writeFileSync(warmEntry, "export const Warm = (props: { n: number }) => {props.n}\n") + await Bun.build({ entrypoints: [warmEntry], plugins: [solidPlugin], target: "bun", external: ["*"] }) + } finally { + fs.rmSync(warmDir, { recursive: true, force: true }) + } +} +// altimate_change end + for (const item of targets) { const name = [ pkg.name,