Repository navigation
ci: package every Electron app, not just the client - #45
Conversation
`turbo run package --filter maximal-client` meant the `electron package` job built one of this workspace's two Electron applications. The two package by different rules: `maximal-client` bundles its dependencies and ships a compiled sidecar, while `@stuffbucket/maximal-electron` holds `node-pty` and `node-llama-cpp` external and materialises their dependency closure into the bundle by hand. Every packaging defect found in the second one was found by hand, because nothing in CI built it: a resolver that walked symlinks instead of real paths, one that appended `node_modules` to a directory already named that, one that never read `optionalDependencies`, and a packager that copied links out of the bundle. Each of those produced a bundle that could not load, and each passed 1,070 unit tests. Dropping the filter rather than naming the second package, so an Electron app added later is packaged without anyone remembering to widen it. Turbo reports `<NONEXISTENT>` for the ten workspace packages with no `package` script and skips them. `verify:package` then runs over the result. It reads the asar listing, the renderer content policy, the fuse wire off the built binary, and all 162 closure placements -- the properties the end-to-end suite cannot see, because it deliberately drives the unpackaged tree. The script has existed for some time and nothing in this repository ran it. Two Forge builds need more than 30 minutes of headroom, and the Electron download cache key now hashes both manifests, so a bump to either one misses rather than restoring a binary the other package no longer uses. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Updated this branch onto current main (#36, #46 have landed since it was cut). The required check Before the update — reached After the update — fails earlier, during packaging itself: Not a regression on main: CI is green on Both symptoms point the same way: the shell's closure is incomplete where the client's is not. Left open and unmerged — it is your PR and the fix is a packaging decision, not a mechanical one. Nothing else is blocked by it. |
The first Linux run of `verify:package` -- which is the first run there has ever been, because this branch is what makes CI package the shell -- failed against a bundle that was correct: FAIL 5 closure placement(s) are missing, first node_modules/@node-llama-cpp/linux-arm64 Two rules drop packages and the check subtracted one of them. A `linux-x64` install carries six `@node-llama-cpp` packages. `linux-arm64` and `linux-armv7l` go for the architecture, which the platform plan accounts for. `linux-x64-cuda`, `linux-x64-cuda-ext` and `linux-x64-vulkan` declare exactly this platform and architecture and go anyway, because they are GPU runtimes nobody asked for -- 505 MB of CUDA. Only `llamaPackagePlan` knows that. Nothing could see it before now. macOS installs ONE package for this target, so the expectation and the archive agreed on every developer machine, and `verify:package` did not run anywhere else. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`main` is red at `6d8f346`, and #57 is red with the same error naming a different file. Neither is a dependency break — which is exactly what the failing pull requests made it look like. ## The bug `@electron/packager` derives its staging base from a constant: ```js // common.js baseTempDir(opts) { return path.join(opts.tmpdir || os.tmpdir(), 'electron-packager') } // packager.js async ensureTempDir() { if (this.useTempDir) { await fs.remove(this.tempBase) // the whole shared directory, every run } } ``` The directory *inside* that base is already unique — `stagingPath` calls `mkdtemp`, which is where `tmp-TRr4aR` comes from — so uniqueness is not what is missing. The unconditional wipe of the shared **parent** is what throws it away. Since #45, CI packages two applications rather than one (`ci.yml`: "Two Forge builds, not one"). So the second build deletes the first's staged tree while asar is midway through reading it. asar crawls, `lstat`s every path, then opens each in turn, so the loss surfaces as ENOENT on a file it had **already stat'ed** — whichever file it reached at that instant. That accounts for the whole symptom set: | Observed | Because | |---|---| | `resources/app/package.json` on `main`, `node_modules/minipass/LICENSE.md` on #57 | whatever asar was reading when the wipe landed | | Failing package moves between `maximal-electron` and `maximal-client` | whichever build started first loses | | `lstat` succeeds, `open` ENOENTs, same process | the tree is deleted between crawl and read | | Green locally, red in CI | one build locally; two concurrently in CI | | Red on `main` with no Electron bump | nothing to do with any dependency | ## The fix `mkdtemp` one level up, in both applications. Packager still wipes the base, but it is one this build created and owns, and `move()` relocates the finished build into `out/`, so nothing accumulates there. Both applications must set it. One alone still leaves the other wiping a directory it does not own. ## Verification Planting another build's staging tree at the shared path — the exact path from the CI error — and running a package: ``` without this change sentinel GONE with this change sentinel PRESENT ``` No timing dependence: the wipe is unconditional, so this is deterministic rather than a race that has to be caught. Separately, a packaged run with this change creates no `electron-packager` base at all, staging under `forge-maximal-electron-AAbIdm` instead. `tsc --noEmit` and `eslint` pass in both packages. The real check is this branch's own `electron package` job, which exercises the two concurrent builds that were colliding. ## Worth reporting upstream A fixed, shared temp base that is `rm -rf`'d once per run makes concurrent `@electron/packager` invocations unsafe for anyone, not just this repository.
turbo run package --filter maximal-clientmeant theelectron packagejob built one of this workspace's two Electron applications.The two package by different rules.
maximal-clientbundles its dependencies and ships a compiled sidecar.@stuffbucket/maximal-electronholdsnode-ptyandnode-llama-cppexternal and materialises their dependency closure into the bundle by hand — 162 placements, 68 of them nested under the package that asked for them.Every packaging defect found in the second one was found by hand, because nothing in CI built it:
node_modulesto a directory already named thatoptionalDependenciesEach produced a bundle that could not load, and each passed 1,070 unit tests.
What changed
The filter is gone rather than widened. Naming the second package would leave the same gap for a third. Turbo reports
<NONEXISTENT>for the ten workspace packages with nopackagescript and skips them; the two real tasks aremaximal-client#packageand@stuffbucket/maximal-electron#package.verify:packageruns over the result. It reads the asar listing, the renderer content policy, the fuse wire off the built binary, and every closure placement — the properties the end-to-end suite cannot see, because it deliberately drives the unpackaged tree (theEnableNodeCliInspectArguments: falsefuse stops Playwright attaching to a packaged binary). The script has existed for some time; nothing in this repository ran it.Headroom and cache key. Two Forge builds need more than 30 minutes. The Electron download cache key now hashes both manifests, so a bump to either misses rather than restoring a binary the other package no longer uses.
Verification
Packaged
@stuffbucket/maximal-electronlocally on darwin-arm64 and ranverify:packageagainst the result: all checks pass, includingthe external modules reach 162 package(s), 0 of them hoistedandall 162 closure placements are packed.actionlintis clean. The now-corrected claim intests/hoisted-dependencies.test.ts— that CI packages only the client — was true when written and is what this PR makes false.CI on this PR is the real check: it is the first run that packages the shell on Linux.