Repository navigation
fix(ci): bundle the Electron ratchet as one entry so shard 2 stops running out of memory - #26053
brennanb2025 wants to merge 2 commits into
Conversation
…ing runner memory
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The change appears ready to merge. Reported checks show unchanged importer results, and Windows path resolution is supported by the pinned esbuild version. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
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. Comment |
…-ratchet-one-bundle
|
Superseded by #26049, which landed the same fix on main (one bundle through a single stdin entry instead of ~2,590 separate entries). Closing this one. |
ELI5
Since 10-06, the second of the five unit-test jobs in PR Checks ("test / tests node 24 2/5") has been dying on many PRs,
mainincluded. No test fails. The job just stops with "The runner has received a shutdown signal" or exit code 143. One test, the check that keeps Electron out of the headless runtime, was asking the bundler to build about 2,600 separate bundles at once. That took about 16 GB of memory. This PR asks for one combined bundle instead. The check gives the same answers and needs about 0.6 GB.What Changed
What you see: CI only. Shard 2 should stop being killed partway through, and the ratchet check (
pnpm run check:runtime-electron-ratchetand its test file) runs in under a second instead of 3–90 s. Nothing in the app changes.The problem:
config/scripts/check-runtime-electron-ratchet.mjsmakes sure nothing reachable from the Orca runtime, or from the structured-chat code that has to run in orcad, importselectron. To do that it bundles those files with esbuild (the JavaScript bundler) and reads esbuild's metafile, which is the list of every module the bundle pulled in and what each one imports. Since #24988 every file in the structured-chat directories is its own entry point, about 2,565 of them. Withwrite: false, esbuild built and returned 2,565 complete bundles even though the script only reads the metafile. The bundles also had to be copied into the vitest worker that runs the test.In the five killed shard-2 runs that were examined, this test file was the only one still running at the moment of the kill: runs 37551764911 (jobs 112581734247, 112573011087), 37554604023 (job 112579486715), 37559551986 (job 112604598018) and 37537601326 (job 112523900418). In passing shard-2 runs (jobs 112585301440, 112524356695) the file took about 92 s, and its "passes on the tree" test took about 76 s against a 120 s timeout. The checked-in timing for the file is 2.5 s.
The mechanism:
collectElectronImportersnow hands esbuild a single generated entry (stdin) that contains oneimport "<absolute path>"line per entry point. esbuild follows the same import graph from the same files, so the metafile lists the same modules with the same imports. It produces one bundle instead of 2,565. Theoutdirplaceholder is gone, because esbuild only needed it for multiple entry points.Measured on macOS (arm64, 64 GB):
/usr/bin/time -l node config/scripts/check-runtime-electron-ratchet.mjs, with RSS also sampled every 0.1 s byps, since esbuild runs as a separate child process thattime -ldoesn't count.The test file alone, run locally: 17/17 pass in 1.7 s.
On this PR's CI (head 6be1282, run 37566129324): shard 2 (
test / tests node 24 2/5) passed.check-runtime-electron-ratchet.test.mjstook 3.4 s there, against ~92 s in passing shard-2 runs before. TheEnforce runtime Electron-import ratchetstep took ~1 s.What I did not measure: memory on the Linux arm64 CI runner itself. GitHub's standard
ubuntu-24.04-armrunner has 16 GB. A ~16 GB peak from one test, alongside the other vitest workers in the shard, is consistent with the runner running out of memory and being shut down, but I have no runner-side memory trace. This PR's own CI run is the check: shard 2 should finish, and this file should take a few seconds.Why
The results are identical, checked before and after. For each of four trees I ran the old per-entry build and the new single-entry build and compared the metafiles directly:
import 'electron'added tosrc/main/native-chat/transcript-read-cache.ts(lane-only file the runtime doesn't load)src/main/native-chat/transcript-read-cache.tsimport … from 'electron/main'added tosrc/main/ipc/worktree-change-invalidators.ts(reached only throughorca-runtime.ts)src/main/ipc/worktree-change-invalidators.tsrequire('electron'))The script never reported import chains or which entry point reached Electron, only the importing modules, so the single entry loses no information. The existing test that adds an Electron import to
transcript-read-cache.tsin memory still fails the check with the expected+ src/main/native-chat/transcript-read-cache.tsline.Alternatives considered:
pnpm linton a laptop.Linked Issue
None. Maintainer PR for a CI failure on
main.Visual Proof
N/A. This is a CI-only change to a lint/test script, with nothing visible in the app. The before/after evidence is the memory and time table above.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
node config/scripts/check-runtime-electron-ratchet.mjs→ok — 0 entries, unchanged.(before and after).vitest run --config config/vitest.config.ts config/scripts/check-runtime-electron-ratchet.test.mjs→ 17/17 pass. The existing tests already cover a seeded lane violation, a violation through anode_modulespackage, and the real tree, so no test needed to change.The old-vs-new metafile comparison above (current tree plus three seeded trees).
oxlintandoxfmt --checkclean on the changed file.Platforms: macOS locally, Linux in CI. Windows: entry paths go into the generated entry through
JSON.stringify, which escapes backslashes, and esbuild resolves absolute Windows paths. Not run on Windows: CI runs this check only on Linux.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Author: @BrennanKB5.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)