Skip to content

fix: re-extract asar entries whose temporary copy was removed - #52807

Closed
codebytere wants to merge 2 commits into
mainfrom
fix-asar-reextract-missing-temp
Closed

codebytere wants to merge 2 commits into
mainfrom
fix-asar-reextract-missing-temp

Conversation

@codebytere

Copy link
Copy Markdown
Member

Description of Change

Closes #52804.

Archive::CopyFileOut() caches the temporary copy it extracts for each entry and returned the cached path without checking the file was still there. Since #29293 archives live for the whole process, so once the OS cleans the temp directory under a long-running app (macOS sweeps $TMPDIR periodically) every later fs.open/createReadStream/execFile of that entry failed with ENOENT, while readFile kept working through the retained archive handle. The cache hit now checks the copy exists and extracts the entry again when it doesn't.

Checklist

  • PR description included and stakeholders cc'd
  • npm test passes
  • tests are changed or added
  • PR release notes describe the change in a way relevant to app developers

Release Notes

Notes: Fixed an issue where reading a file inside an asar archive with fs.createReadStream or child_process could fail with ENOENT in long-running apps after the OS cleared the temporary directory.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Aug 14, 2026
Archive::CopyFileOut() caches the temporary copy it extracts for each
entry and returned the cached path without checking that the file is
still there. Archives live for the whole process, so once the OS cleans
the temp directory under a long-running app (macOS sweeps $TMPDIR
periodically) every later fs.open/createReadStream/execFile of that
entry failed with ENOENT while readFile kept working. Check the cached
copy exists and extract the entry again when it does not.

Closes #52804.
@codebytere
codebytere force-pushed the fix-asar-reextract-missing-temp branch from 6a0b93e to ebdb1bc Compare August 14, 2026 08:26
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. labels Aug 14, 2026
@codebytere
codebytere requested a review from deepak1556 August 14, 2026 13:53
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Aug 15, 2026
@codebytere codebytere closed this Aug 16, 2026
@codebytere
codebytere deleted the fix-asar-reextract-missing-temp branch August 16, 2026 06:58
@0xdevalias

0xdevalias commented Aug 18, 2026 •

Copy link
Copy Markdown

@codebytere I see that #52811 looks like it was a testing bug you ran into after creating this PR, and that it landed; but from what I saw there, it didn't look like it contained this PR or a related fix; so I am curious why you closed this PR, if there is another newer/rebased/etc version of this fix I should be watching for; and/or whether you just found that this wasn't actually a good solution to #52804, etc


Edit: After exploring with GitHub Copilot (GPT-5.6 Terra), I believe this may have been closed because there is a more broader PR related to ASAR file improvements/etc:

Best evidence: PR #52807 appears to have been closed in favor of the broader, still-open PR #52833, but there is no explicit closure explanation or cross-reference confirming that. The original issue, #52804, is still open, so the fix has not landed yet.

#52833 changes the relevant architecture instead of repairing the stale cache. It removes Archive::CopyFileOut() from fs.open, fs.createReadStream, fs.promises.open, descriptor reads, streams, and copy APIs. Packed ASAR entries are read directly from a duplicated retained archive FD, so there is no extracted temp file for macOS to sweep away.

That directly solves the reported createReadStream / fs.open stale-temp-file failure in #52804, more comprehensively than #52807’s “check whether the cached extracted path still exists; re-extract if not” approach.

However, #52833 is not a perfect one-for-one replacement. It explicitly leaves child_process.execFile*, process.dlopen, and native-module loading on the temp-copy path because they require a real OS path. So #52833 addresses the issue’s createReadStream case, but apparently does not address #52807’s broader claim that execFile should recover after its cached temp copy disappears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver/patch backwards-compatible bug fixes target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: createReadStream fails for ASAR entry after extracted temp file is deleted

2 participants