Skip to content

fix: run unit tests with Bun's per-file isolation, load the forked Bash grammar, and update code-gauge - #1474

Merged
exKAZUu merged 2 commits into
mainfrom
chore/update-code-gauge-tree-sitter-bun-workarounds
Oct 10, 2026
Merged

exKAZUu merged 2 commits into
mainfrom
chore/update-code-gauge-tree-sitter-bun-workarounds

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Why

  1. Bun 1.4.3 fixes the spawnSync hang. wb test passed --no-isolate (fix(wb): run parallel unit test workers without per-file isolation #1421) only because, in Bun 1.4.2, a spawnSync in a --parallel worker could miss its child's exit when the previous file's discarded stdout/stderr writers were garbage-collected during the call (oven-sh/bun#34069). The fix, oven-sh/bun#44581, describes exactly that mechanism and is included in bun-v1.4.3 (the tag is 19 commits ahead of its merge commit and 0 behind). This repository already pins Bun 1.4.3.
  2. The vendored Bash grammar was falling behind. fix(wbfy): use established shell parser runtime during bootstrap #1422 vendored a tree-sitter-bash.wasm built from @willbooster/tree-sitter-bash 2.1.0 and loaded it with upstream web-tree-sitter, so no fresh organization package could block wbfy's first install before wbfy refreshes the global release-age exclusions. Renovate cannot update a vendored file, and the grammar is at 3.0.4 now. Its ABI 16 cannot be loaded by upstream web-tree-sitter 0.27 (Incompatible language version 16. Compatibility range 13 through 15). The organization is moving to the forked runtime and grammars. Both are exempt from the release-age gate, and that exemption shipped in feat(wbfy): exempt all our tree-sitter packages from the release-age gate #1405, before fix(wbfy): use established shell parser runtime during bootstrap #1422.
  3. code-gauge 10.2.x is available. It brings grammar updates, a more precise count of near-miss duplicates, and two bug fixes.

Requirements

  • required: update code-gauge and tree-sitter-bash to the latest versions
  • required: remove the Bun 1.4.2 workarounds that Bun 1.4.3 makes unnecessary
  • required: use the organization's forked tree-sitter runtime and grammars, which are exempt from the release-age gate
  • required: wb test keeps running unit test files in parallel worker processes
  • chosen: drop --no-isolate for every Bun version and rely on the documented Bun >= 1.4.3 pin, because Renovate delivers Bun 1.4.3 in the same patch group as a wb patch release (fix(deps): update all patch dependencies #1471 bumped mise.toml's Bun together with packages/wb), and the remaining gap (wbfy writing 1.4.2 into a repository without a newer pin) closes when mise's release-age gate exposes 1.4.3 on 2026-10-17; rejected alternative: a bun --version check in wb that keeps --no-isolate below 1.4.3, which adds a spawn per test run and transitional code to delete a week later
  • chosen: keep passing [test] timeout as bun test --timeout, because oven-sh/bun#7789 and oven-sh/bun#43787 are still open and a preload's setDefaultTimeout still reaches only one file of the non-isolated e2e run on Bun 1.4.3
  • chosen: keep wbfy's ban on child_process imports and its Bun floor at 1.4.0, because raising the floor to 1.4.3 would make wbfy abort in repositories pinned to 1.4.2 until mise's release-age gate exposes 1.4.3 to wbfy's own Bun pinning

Customer Summary

  • wb test runs each unit test file in a fresh global, module registry, and process.env again, while still using parallel worker processes, so test files no longer need to restore what they change.
  • Target repositories must pin Bun 1.4.3 or later; the synchronous-spawn restriction on their tests is gone.
  • wb verify's code-gauge findings may change slightly with code-gauge 10.2.
  • wbfy parses shell scripts with the forked Bash grammar 3.0.4.

Technical Summary

  1. packages/wb/src/scripts/execution/baseScripts.ts: testUnit passes --parallel without --no-isolate.
  2. docs/expected-repository-rules.md: the unit-test rule requires Bun >= 1.4.3 instead of asynchronous spawns. Because --parallel implies --isolate, each file gets a fresh global, module registry, and process.env (verified on Bun 1.4.3), so the rule no longer asks files to restore what they change. The --no-isolate-era helper code goes with it: createTempDir (packages/wb/test/helpers/shared.ts) no longer restores process.env at file end, and the buildWb comment states the remaining reason for its once-per-run marker.
  3. setDefaultTimeout in a preload now works in isolated unit runs but still reaches only one file of the sequential, non-isolated e2e run (oven-sh/bun#43787), and Bun still ignores [test] timeout (oven-sh/bun#7789). The docs and packages/wb/src/utils/bunfig.ts say so, and wb keeps passing --timeout.
  4. packages/wbfy/src/utils/shellParser.ts and packages/wbfy/package.json: wbfy loads @willbooster/tree-sitter-bash/tree-sitter-bash.wasm through @willbooster/web-tree-sitter 1.4.5, which the build keeps external. The vendored WASM and its license are deleted.
  5. packages/wb/package.json: code-gauge 10.1.0 → 10.2.2.

Testing

  • bun run verify passed.
  • bun wb test -w packages/wb test/unit: 484 tests passed under the new --parallel command (which runs this repository's own suites), before and after createTempDir stopped restoring process.env.
  • bun wb test -w packages/wbfy test/unit: 369 passed and 2 failed locally in globalReleaseAgeGate.test.ts. Those 2 fail identically on main on this machine: the script's mise reads the developer's real ~/.config/mise/config.toml, which is untrusted under the test's temporary HOME. CI's full test job passed, including them.
  • Per-file isolation on Bun 1.4.3: with bun test --parallel=1, a file's changes to globalThis, an imported module, and process.env are invisible to later files; with --no-isolate they leak. A preload's setDefaultTimeout applied to every file under --parallel, but to only one file without it.
  • Shell parsing: with the forked runtime and grammar 3.0.4, a script covering assignments, &&/||, subshells, pipes, $(...), backquotes, time -p, for, if, and $((...)) parses to the same tree as the previous runtime and vendored grammar. The built wbfy bundle also resolves the grammar.
  • Not run: the standalone hang reproduction in Docker, because Docker was unavailable. The Bun fix is confirmed from the release tag and the PR's description instead.

Notes

  • Until 2026-10-17, mise's 7-day release-age gate hides Bun 1.4.3, so wbfy writes 1.4.2 into a repository that has no newer pin. Repositories still on Bun 1.4.2 can hit the spawnSync hang under this wb until Renovate or wbfy lifts their pin.
  • wbfy's child_process import ban and its minimumBunVersion can be raised to 1.4.3 once that gate passes.

…sh grammar, and update code-gauge

Bun 1.4.3 includes the spawnSync fix (oven-sh/bun#44581), so `wb test` no longer needs
`--no-isolate` and the unit-test rule no longer requires asynchronous spawns. wbfy loads the
Bash grammar from @willbooster/tree-sitter-bash 3.0.4 through @willbooster/web-tree-sitter
instead of a vendored WASM file, and wb uses code-gauge 10.2.2.

Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request optimizes the test execution environment by leveraging fixes in Bun 1.4.3, allowing for more efficient parallel test execution. It also updates the shell parsing infrastructure by migrating to forked tree-sitter packages, ensuring better maintainability and compatibility with the organization's release policies. Finally, it includes a minor version bump for code-gauge to incorporate recent improvements.

Highlights

  • Bun 1.4.3 Upgrade: Removed the '--no-isolate' workaround for unit tests, as Bun 1.4.3 resolves the spawnSync hang issue.
  • Tree-sitter Migration: Transitioned to the organization's forked tree-sitter runtime and Bash grammar (v3.0.4) to avoid compatibility issues and release-age gate restrictions.
  • Dependency Updates: Updated code-gauge to version 10.2.2 for improved grammar and bug fixes.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


Tests run fast in parallel flow, Bun 1.4.3 makes them go. Grammars updated, bugs are gone, Coding work goes marching on.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the standard web-tree-sitter dependency with @willbooster/web-tree-sitter and @willbooster/tree-sitter-bash, loading the bash grammar directly via package resolution. It also upgrades code-gauge to version 10.2.2, removes the --no-isolate flag from unit tests (as the repository now pins Bun >= 1.4.3), and updates the documentation and comments to reflect these changes. There are no review comments, and I have no additional feedback to provide.

…leftover restores

`bun test --parallel` gives each file a fresh global, module registry, and `process.env`, so
test files no longer restore what they change, and `createTempDir` no longer restores
`process.env`. A preload's `setDefaultTimeout` still reaches only one file of the
non-isolated e2e run.

Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
@exKAZUu exKAZUu self-assigned this Oct 10, 2026
@exKAZUu
exKAZUu merged commit 2de2aad into main Oct 10, 2026
4 checks passed
@exKAZUu
exKAZUu deleted the chore/update-code-gauge-tree-sitter-bun-workarounds branch October 10, 2026 16:37
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