Repository navigation
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
43.4.0
What operating system(s) are you using?
macOS
Operating System Version
macOS 26.6 (25G72)
What arch are you using?
arm64 (including Apple Silicon)
Last Known Working Electron version
Unknown
Does the issue also appear in Chromium / Google Chrome?
No. This is specific to Electron's ASAR filesystem integration.
Expected Behavior
After a temporary copy of a packed ASAR entry is removed while Electron remains running, a later fs.createReadStream() call for that ASAR entry should recreate the temporary copy or otherwise read the packed bytes successfully.
Actual Behavior
The first fs.createReadStream() succeeds. If its extracted temporary file is then deleted while Electron remains running, every later fs.createReadStream() for the same ASAR entry fails with ENOENT for the deleted temporary pathname. A buffered fs.readFileSync() of the same packed entry continues to succeed.
Example output from the testcase:
Extracted copy: /var/folders/.../T/.com.github.Electron.ul88vz
Deleted the extracted copy while Electron remains running.
readFileSync after deletion: "electron-asar-stale-cache-repro-7e8fa4f9\n"
REPRODUCED: ENOENT opening cached path /var/folders/.../T/.com.github.Electron.ul88vz
Testcase Gist URL
Run with:
git clone https://gist.github.com/b28e27ea290913bbe4510eeaad7edaf3.git
cd b28e27ea290913bbe4510eeaad7edaf3
npm install
npm startAdditional Information
This was first encountered in openai/codex#37551, where a long-running Electron process could no longer open Codex windows after its extracted .com.openai.codex.* ASAR files disappeared. The original packed entries remained readable, and recreating the expected temporary files restored the running application. The validated diagnosis and workaround are documented in openai/codex#37551 (especially this investigation comment and the upstream-context follow-up).
This report is specifically about recovery from a missing cached extraction file, rather than whether temporary files should be cleaned up at process exit.
Related prior reports:
- [Bug]: tray icon will eventually disappear when packed in asar archive #30911
- reports the same temporary-file lifetime problem for an ASAR-backed tray icon after the temp directory is cleared. It was closed for inactivity rather than by a generic cache fix.
- Temporary .ico files created by NativeImage should be cleaned #22500
- notes that the OS may clean files from the temporary directory while the application is alive.
- fix: change ASAR archive cache to per-process to fix leak #29293
- made the ASAR archive cache process-wide. That fixed [Bug]: Main Process Can Leak Memory/File Handles/Temp Files When Renderer Requests Files From ASAR #29292, but also makes the archive's extracted-path cache long-lived.
- fix: Electron creates temporary icon files and does not delete them after use #52424
- recently avoided
CopyFileOut()for one packed-ICO call site, but did not change generic missing-file recovery.
- recently avoided
In-depth investigation
Archive::CopyFileOut() retains extracted files in external_files_. Its cache-hit branch returns the stored pathname without checking whether it still exists:
Electron's Node filesystem wrapper calls archive.copyFileOut() from its fs.open() override. fs.createReadStream() reaches that wrapper, so a later stream open receives the stale pathname and the underlying OS open fails with ENOENT:
- https://github.com/electron/electron/blob/main/lib/node/asar-fs-wrapper.ts#L179-L237
- https://github.com/electron/electron/blob/main/lib/node/asar-fs-wrapper.ts#L1218-L1229
The standalone testcase uses only the public fs behavior to trigger the failure. It locates the first extracted copy by its unique contents, deletes it, confirms readFileSync() can still read the original packed bytes, and then observes createReadStream() failing against the same deleted pathname.
Electron's own ASAR URL loader already avoids extraction for packed entries and streams from a duplicate of the archive's retained file handle. PR #52283 similarly made retained-handle reads robust when an updater atomically replaces app.asar. Neither path repairs a missing CopyFileOut() cache entry.
A minimal fix could check the cached path under external_files_lock_, evict the entry when it no longer exists, and extract it again. A fully race-resistant solution may also need retry/invalidation if the file disappears between an existence check and the consumer's subsequent open().
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields👍 Does Not Block Stable
Activity
fix: re-extract asar entries whose temporary copy was removed
0xdevalias commentedon Aug 18, 2026
It looks like @codebytere opened a PR with a bugfix for this, but later closed it:
Currently not sure of the context around that, but asked for clarity in this comment:
Edit: Some further context:
codebytere commentedon Aug 23, 2026
@0xdevalias #52807 was closed because #52833 removes the temp-copy path entirely (fds, streams and copies are served from the archive now), which fixes this at the source. that's landed for 45; it's too large to backport, so 43/44 keep the current behaviour.
0xdevalias commentedon Aug 24, 2026
@codebytere Thanks for confirming, and awesome that it's landed for future versions! No worries about not being able to backport.
fix(desktop): read asar files without Electron's temp copies (closes #…