Skip to content

fix: warm the Solid plugin before the release bundle and retry a failed build once - #1823

Merged
ralphstodomingo merged 1 commit into
mainfrom
fix/release-build-eisdir-flake
Nov 23, 2026
Merged

ralphstodomingo merged 1 commit into
mainfrom
fix/release-build-eisdir-flake

Conversation

@ralphstodomingo

@ralphstodomingo ralphstodomingo commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #1694

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The EISDIR on @babel/traverse is a race in Bun 1.3.14's resolver, not the bun install calls in build.ts (those finish before Bun.build starts). The binary bundles @babel/core, so the bundle thread resolves Babel's packages from the symlinked store, while the Solid plugin's Babel lazily requires the same packages on the JS thread. Bun caches whether each symlink is a file or a directory without a lock, so the losing side can read a package directory as a file. Bun 1.4 locks that lookup.

  1. build.ts runs the Solid plugin once on a throwaway .tsx, in a build that resolves nothing, before the real bundles, so Babel's lazy requires happen before any bundle thread starts.
  2. release.yml retries a failed build once in a fresh process, with a warning on the run, so one flaky target can't hold up the release.

How did you verify your code works?

  • Synthetic repro on Bun 1.3.14: 52 of 100 builds hit the same EISDIR when a plugin resolved on the JS thread, 0 of 300 without.
  • strace on the real build.ts (linux-x64): JS-thread lookups under node_modules during the main bundle went from 117 to 0.
  • linux-x64 binary runs, fresh-start test and release-critical tests pass, typecheck clean, retry loop simulated.

Investigation notes: #1823 (comment). Claims and Codex review log: #1823 (comment).

Cost side effects

None.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

🤖 Generated with Claude Code

https://claude.ai/code/session_01VEmKQv6E2XpAgL5eJE8RYi

Summary by CodeRabbit

  • Chores
    • Release builds now retry once after a failed build attempt, helping recover from intermittent failures.
    • Build preparation has been updated to improve consistency across target builds.

…ed 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VEmKQv6E2XpAgL5eJE8RYi
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The release workflow retries a failed target build once in a fresh process. Before building target binaries, the build script runs a temporary Solid-plugin warm-up build and removes its temporary directory.

Changes: Release build flow

Layer / File(s) Summary
Retry target builds
.github/workflows/release.yml
The build step attempts the target build up to twice. It exits on success, warns after the first failure, and fails if the second attempt also fails.
Warm up the Solid plugin
packages/opencode/script/build.ts
The script creates a temporary TSX entrypoint and builds it with solidPlugin and externalized imports before target builds. It removes the temporary directory in a finally block.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: anandgupta42, sahrizvi

Merge Risk: Minimal · up to 050a2

This change makes release builds more resilient to an intermittent resolver race by warming the Solid plugin before bundling and retrying a failed build once. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names both changes in the PR: a warm-up of the Solid plugin before the release bundle in build.ts, and a single retry of a failed build in release.yml. The title is specific, follows the con…
Description check Passed The description follows the required template. It includes the issue link (Closes #1694), the bug fix type, a detailed 'What does this PR do?' section explaining the root cause and both changes, verif…
Linked Issues check Passed Directly linked issue #1694 asks for a retry of the build step, or a rerunnable matrix job, so one flaky target does not block publishing. The PR adds a retry in .github/workflows/release.yml. Each ta…
Out of Scope Changes check Passed The PR changes two files. The release.yml change adds the build retry that #1694 requests. The build.ts change adds a temporary Solid-plugin warm-up build and removes its directory in a finally block.…
Full details: Title check

Explanation

The title names both changes in the PR: a warm-up of the Solid plugin before the release bundle in build.ts, and a single retry of a failed build in release.yml. The title is specific, follows the conventional 'fix:' prefix, and matches the main objectives. At 82 characters it is slightly long but still clear.

Full details: Description check

Explanation

The description follows the required template. It includes the issue link (Closes #1694), the bug fix type, a detailed 'What does this PR do?' section explaining the root cause and both changes, verification steps, a cost side effects section stating 'None', and a completed checklist. The template's required cost side effects section is filled in. The description is long and detailed, but it is not clearly AI-generated boilerplate, and the template's sections are all present.

Full details: Linked Issues check

Explanation

Directly linked issue #1694 asks for a retry of the build step, or a rerunnable matrix job, so one flaky target does not block publishing. The PR adds a retry in .github/workflows/release.yml. Each target build runs at most twice, in fresh bun run processes. The first success exits 0. A first failure emits a warning. Two failures exit nonzero. This meets the retry request. The issue also asks whether package layout or resolution caused the failure, and whether pinning or pre-installing Babel removes the race. The PR addresses this with a warm-up step in packages/opencode/script/build.ts. That step runs the Solid plugin on a throwaway .tsx file before the release bundles, so Babel's lazy requires finish before bundle threads start. The issue sets no acceptance criteria for the warm-up approach. The author reports a synthetic reproduction (52/100 failures with JS-thread resolution, 0/300 without) and a strace count (117 to 0 JS-thread node_modules lookups). These results come from the PR description and were not re-run here. No coding requirement from #1694 remains unmet. Evidence is based on the whole-PR summary; the diff was not re-read.

Full details: Out of Scope Changes check

Explanation

The PR changes two files. The release.yml change adds the build retry that #1694 requests. The build.ts change adds a temporary Solid-plugin warm-up build and removes its directory in a finally block. The warm-up targets the Babel resolution race named in #1694's investigation scope. Both changes connect directly to the linked issue. The summary reports no changes to exported declarations. The author states that ci.yml receives the warm-up but not the release retry; this is a documented scope choice, not an unrelated change. The PR description reports no unrelated changes. The assessment relies on the whole-PR summary; the diff was not re-read.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit watches builds begin,
A fresh process tries again.
The plugin warms, then hops away,
The temp files vanish by the day.
Two green runs, and off we play!

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 17c6d3ed-16c8-4089-a456-032255419a4c
Commits

Reviewing files that changed from the base of the PR and between c00b2dc and 050a289.

Files selected for processing: 2

  • .github/workflows/release.yml
  • packages/opencode/script/build.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@ralphstodomingo

Copy link
Copy Markdown
Contributor Author

Investigation notes

Where it breaks. Both failures read the same path: the @babel/traverse symlink inside node_modules/.bun/@babel+core@7.28.0+e33be1330ecc2599/node_modules/@babel/. v0.12.10 printed the bundler's own read error ("EISDIR reading file:"), so the bundle thread lost there. v0.12.12 reported it against the plugin's load of packages/tui/src/plugin/runtime.tsx, which points at the JS thread losing that time.

Why Babel is in both places. src/plugin/tui/runtime.ts imports @opentui/solid/runtime-plugin-support/configure, which pulls the Solid Babel transform (and @babel/core) into the binary. The bundle has 50 @babel/core modules. Most of Babel's packages have no exports map, so Bun resolves them through its file-or-directory check on the symlink. Packages with an exports map skip that check, which is why it is always Babel.

The Bun code. In 1.3.14 the directory-entry cache (src/resolver/fs.zig, Entry.kind) sets need_stat = false before the stat and its result are written, and takes no lock. A placeholder kind of .file stays in place until then. Each Bun.build also re-reads directories under a new resolver generation, which resets every symlink entry to need-stat with that .file placeholder. So a thread that reads the entry in that window sees a file. Reading the source, Bun 1.4.5 (src/resolver/fs.rs) double-checks under the entry's mutex and clears the flag only after the write. Bun's bundle thread resolves import records on one thread, so the second party is the JS thread, here the Solid plugin's Babel.

Repro. Fixtures of N files each importing M symlinked packages with no exports map (default 400 × 40):

Bun 1.3.14 builds EISDIR
no JS-thread resolution, one build per process (400 × 40 and 2000 × 200) 1,200 0
no JS-thread resolution, 300 builds in one process 300 0
plugin resolving the same packages on the JS thread, 5 fresh processes × 20 builds 100 52
same, one build per process (400 × 40) 200 1
same, one build per process (60 × 400 and 200 × 150) 200 0

The real-shaped bundle (the opencode entrypoints with the Solid plugin, no compile, no fix) passed 200 of 200 fresh runs here. That fits what CI shows: since 2026-09-21, 2 failures in 80 release legs, and none in the last 100 main-branch runs of the ci.yml sanity job, which runs the same build.

What the warm-up changes. strace on script/build.ts --target-index=1, with the ci.yml sanity settings, counting the main thread's syscalls between markers around the main Bun.build:

  • before: 261 syscalls, 117 under node_modules (@babel/helper-compilation-targets, @babel/generator, browserslist, caniuse-lite, ...)
  • after: 12 syscalls, 0 under node_modules

The warm-up build itself resolves nothing on the bundle thread (all imports external, entry in a tmpdir). So Babel's first transform runs in a build that has no store directories to race over.

Output. I compared the unminified bundle with and without the warm-up. 8 of 11 warm runs were byte-identical to every cold run. The other 3 differ only by a consistent renaming of 26 local identifiers in index.js and 22 in worker.js, with the same token count, the same non-identifier text and a one-to-one name mapping. The likely cause: with Babel warm, plugin results interleave with native parses, so Bun's renamer numbers symbols in a different order.

Retry. Simulated the step under bash -e with a stub bun: a build that passes runs once, one that fails then passes runs twice with the warning and exits 0, and one that always fails runs twice and exits 1. A matrix leg could already be re-run on its own with "Re-run failed jobs" (that's how v0.12.10 and v0.12.12 shipped). The retry drops that manual step. It is a fresh process because Bun keeps a misread entry for the life of the process.

@ralphstodomingo

ralphstodomingo commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex review log

Claims (each falsifiable by a concrete trace):

  • C1. On this head, the JS thread does no node_modules resolution during any per-target Bun.build in packages/opencode/script/build.ts for the current sources: everything the Solid plugin's Babel loads lazily is loaded during the warm-up. Before this change it did (Babel's lazy requires on the first .tsx transform), in the same node_modules/.bun store directories the bundle thread reads for the @babel/core the binary embeds.
  • C2. The warm-up Bun.build resolves nothing on the bundle thread. Every import is external and the entry sits in a fresh tmpdir outside the repo, so it shares no node_modules directory with Babel's lazy requires.
  • C3. The warm-up doesn't change what goes into the release binary. The per-target Bun.build call (options, plugins, entrypoints, defines) is unchanged, and the plugin's per-file transform output doesn't depend on whether the warm-up ran.
  • C4. The warm-up leaves nothing behind (its tmpdir is removed in finally), and a warm-up failure fails the build instead of being swallowed.
  • C5. In .github/workflows/release.yml the build step runs build.ts at most twice, each time as a new bun run process. It exits 0 if and only if an attempt exits 0, exits non-zero when both fail, and writes a ::warning:: when attempt 1 fails. No other step, job, env var or matrix entry changes.
  • C6. A retry can't upload a stale or mixed dist/. The upload runs only after the build step succeeds, and the succeeding attempt runs rm -rf dist before it writes anything.

Disclosed residuals (accepted, not findings):

  • R1. The race is still in Bun 1.3.14. The warm-up covers the lazy requires the current sources reach. If new syntax makes Babel reach one the warm-up file doesn't, that lookup can race again; the retry covers it, and moving the build to Bun 1.4 is the real fix (a separate decision).
  • R2. Bundle output can vary between runs by a consistent renaming of local identifiers (3 of 11 warm runs vs 0 of 10 cold), because plugin results now interleave with native parses. The token stream is otherwise identical.
  • R3. The retry also retries deterministic failures once, which costs one more build before the step fails.
  • R4. ci.yml's sanity build gets the warm-up but not the retry; it doesn't block a release.
  • R5. The real build didn't fail locally in 200 runs without the fix. The mechanism was reproduced on a synthetic fixture, and the before/after on the real script is by strace.

Rounds

  • Round 1, 050a289, local Codex CLI (read-only, static, no builds run): no violation of C1–C6. It checked the warm-up ordering, the external imports, the unchanged per-target build options, cleanup and failure propagation, the retry's exit and warning behaviour, the dist cleanup before artifacts are written, and C1's lazy-load coverage against the Solid/Babel and Bun resolver sources. Review ends here.

Other reviewers on 050a289 (after the ready flip):

  • cubic P2, release.yml:97: the retry could outrun the build job's 15-minute timeout. Declined with timings: across the last six release runs the build step takes 12–26s and whole build jobs 61–109s; the two EISDIR failures died 3s and 9s into the step. (thread)
  • Kilo (advisory), build.ts:521: a failed warm-up resolves with success: false and is swallowed. Declined with a check on Bun 1.3.14: a syntax error through the Solid plugin, a throwing onLoad and a missing entry all make Bun.build reject, so C4 holds. (thread)

@ralphstodomingo
ralphstodomingo marked this pull request as ready for review November 23, 2026 07:10

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread .github/workflows/release.yml Resolved
Comment thread packages/opencode/script/build.ts Resolved
@kilo-code-bot

kilo-code-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/script/build.ts 521 Warm-up Bun.build result is not checked, so a failed transform silently no-ops the mitigation instead of failing the build (repo pattern at packages/cli/script/build.ts:105).

Note: the retry's interaction with the build job's unchanged timeout-minutes: 15 is already raised by an existing inline comment on .github/workflows/release.yml:97, so it is not duplicated here.

Files Reviewed (2 files)
  • .github/workflows/release.yml - 0 new issues (existing cubic timeout thread covers the retry budget)
  • packages/opencode/script/build.ts - 1 issue

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 85.2K · Output: 18.9K · Cached: 993.8K

Review guidance: REVIEW.md from base branch main

@sahrizvi sahrizvi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Consensus review: APPROVE. Panel: Claude (lead) and Codex (independent read-only pass, then a cross-check). Neither found anything above a nit.

What I checked by running it (Bun 1.3.14, the version release.yml pins):

  • Release binary unchanged. The per-target Bun.build call (options, plugins, defines, entrypoints) is byte-identical to the base. I built the unminified linux-x64 bundle three times at base and three times at head. All 9 base/head pairs are byte-identical, and so is a full dist/ comparison that includes the parser worker. I saw no identifier renaming locally. The compiled darwin-arm64 binaries differ only by the checkout path baked into __dirname, the sourcemap debugIds and the code signature. Both print the same --version, and their --help output is identical.

  • Warm-up. mkdtempSync under os.tmpdir() is removed in finally both when the warm-up succeeds and when it fails. Nothing is written under the repo. The Solid plugin has only onLoad hooks, so external: ["*"] covers every import. The JSX is compiled to @opentui/solid imports, so Babel's Solid preset really runs. A syntax error, a throwing onLoad and a missing entry all make Bun.build reject. Breaking the warm-up in the real build.ts makes it exit 1 before any target is built, and leaves no tmpdir behind.

  • Mechanism. I hooked require resolution during each Bun.build. At base, the main bundle triggers 38 JS-thread node_modules lookups (@babel/helper-compilation-targets, browserslist, caniuse-lite, ...). At head, the main bundle triggers 0 and all 38 happen in the warm-up. I ran a synthetic fixture (400 files × 40 symlinked packages with no exports map, 5 processes × 20 builds) in oven/bun:1.3.14 on Linux:

    • With a plugin resolving those packages on the JS thread in every build: 32 of 100 builds hit EISDIR.
    • Same plugin with the lookups done once before the builds (the warm-up's shape): 0 of 100.
    • Without the plugin: 0 of 100.
    • Same racing plugin on Bun 1.4.5: 0 of 100.

    On macOS arm64 the race never fired (0 of 500). In the source, 1.3.14's Entry.kind clears need_stat before it writes the stat result, and takes no lock. 1.4.5 checks the flag again under the entry's mutex and clears it only after the write.

  • Retry. I ran the step under bash --noprofile --norc -eo pipefail with a stub bun. It exits 0 exactly when one attempt exits 0. This holds when attempt 2 exits 0 after printing to stderr, and when attempt 1 dies by SIGKILL or SIGSEGV. Each attempt is a separate process, and attempt 1's failure prints the ::warning::. rm -rf dist sits inside build.ts, so every attempt clears dist before building. The upload step has no if:, so it still needs the build step to succeed. The matrix, env, permissions and secrets are unchanged, and all 8 legs run on ubuntu-latest.

  • Timing. I looked at the build legs of the last six release runs. The build step took 12–26 s and the job 59–109 s. The two failed legs died 3 s and 9 s into the step. A second attempt fits easily in the 15-minute job timeout. Locally, head builds take the same time as base (about 8 s).

  • Suites at head. bun run typecheck: pass. Marker guard: pass. By hand, every added line in build.ts and release.yml sits inside altimate_change markers. test/branding/, test/install/ and the build-related tests: 570 pass, 0 fail, the same as base. bun run pre-release: 4/4 checks pass. The ci.yml sanity build settings (--target-index=1, fixture catalog): pass.

Remaining items, none blocking (details in the PR comment):

  • The warning doesn't show the exit code: cosmetic.
  • The warm-up should go when the build moves to Bun 1.4: safe as a follow-up. Upstream opencode moved from 1.3.14 to 1.4.0 on 2026-08-31 and has no warm-up.
  • A build that hangs instead of failing gets no second attempt within the job timeout: edge case, and the exposure to hangs predates this PR.
  • Disclosed by the author: identifier renaming, a retry of deterministic failures, no retry in ci.yml. These are cosmetic, or safe to handle in a follow-up.

@sahrizvi

Copy link
Copy Markdown
Collaborator

Nits and follow-ups from the consensus review (Claude + Codex). None of them blocks the merge.

  1. Nit, .github/workflows/release.yml lines 98–103: the ::warning:: doesn't include the exit code of the failed attempt. So a runner kill (137) and an ordinary build failure (1) look the same on the run summary. You could save it with rc=$? in an else branch and print it in the warning. Cosmetic.
  2. Follow-up, packages/opencode/script/build.ts lines 507–526: the warm-up exists only because of Bun 1.3.14. Upstream opencode moved from bun@1.3.14 to bun@1.4.0 on 2026-08-31 (now bun@1.4.4) and has no warm-up. Our synthetic fixture shows no EISDIR on 1.4.5 even with the racing plugin. A tracking issue to remove this block when the fork moves to Bun 1.4 would stop it outliving its reason. The code comment already says so.
  3. Edge, .github/workflows/release.yml line 98: there is no timeout per attempt. A build that hangs instead of failing would use up the 15-minute job budget on attempt 1 and never reach attempt 2. The failures seen so far died within seconds, so this is optional hardening and not something this PR introduced.
  4. Disclosed residuals, confirmed acceptable: output can vary by identifier renaming. I saw none in 3×3 local runs, and every base/head pair was byte-identical. The retry also retries deterministic failures, at a cost of about 20 s. ci.yml's sanity build gets the warm-up but not the retry; it passed locally with the sanity settings.

@dev-punia-altimate

Copy link
Copy Markdown
Contributor

🤖 Code Review — OpenCodeReview (Gemini) — No Issues Found

No supported files changed.

@ralphstodomingo
ralphstodomingo merged commit 6e3fe1d into main Nov 23, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

release: Build (win32-x64) failed with EISDIR on @babel/traverse while the other targets built (v0.12.10 run, re-run without changes)

3 participants