Repository navigation
fix(package): give each Forge build a staging base it owns - #69
Merged
Merged
Conversation
`main` is red at 6d8f346 with ENOENT: no such file or directory, open '/tmp/electron-packager/tmp-TRr4aR/resources/app/package.json' and #57 is red with the same error naming a different file. Neither is a dependency break, which is what the failing pull requests made it look like. @electron/packager derives its staging base from a constant: baseTempDir(opts) { return path.join(opts.tmpdir || os.tmpdir(), 'electron-packager') } and `ensureTempDir` runs `fs.remove` over the whole of it at the start of 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, so the second Forge build deletes the first's staged tree while asar is midway through 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, in whichever application started first. That is why the named file and the failing package move between runs, and why it reads as a break in whatever happens to be under review. Fixed by 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. Verified by planting another build's staging tree at the shared path and running a package: without this change sentinel GONE with this change sentinel PRESENT and by confirming a packaged run creates no `electron-packager` base at all, staging under `forge-maximal-electron-AAbIdm` instead. Both applications must set it; one alone still leaves the other wiping a directory it does not own.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mainis red at6d8f346, 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/packagerderives its staging base from a constant:The directory inside that base is already unique —
stagingPathcallsmkdtemp, which is wheretmp-TRr4aRcomes 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,lstats 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:
resources/app/package.jsononmain,node_modules/minipass/LICENSE.mdon #57maximal-electronandmaximal-clientlstatsucceeds,openENOENTs, same processmainwith no Electron bumpThe fix
mkdtempone level up, in both applications. Packager still wipes the base, but it is one this build created and owns, andmove()relocates the finished build intoout/, 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:
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-packagerbase at all, staging underforge-maximal-electron-AAbIdminstead.tsc --noEmitandeslintpass in both packages. The real check is this branch's ownelectron packagejob, 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/packagerinvocations unsafe for anyone, not just this repository.