Repository navigation
Description
This issue occurs on both Electron v30.0 and v33.0 but only reproducible on Windows (x64). We have tested extensively on OSX and can't reproduce but Windows 32-bit and Linux are untested.
Essentially we have an application with lots of image resources packaged into the .asar archive. Our application will frequently load images from the archive - depending on state in our application, we completely unload assets from memory so we are often re-requesting them. We have used both XHR + file:// requests and the fs module directly and the result is the same.
After some time (ie continued / frequent requests of assets) - the files start to ENOENT as if they don't exist. Once the files start to ENOENT, they can never be read again unless the application is restarted. How long this takes to occur may vary but it is almost 100% reproducible for us.
If we disable asar packing and just bundle without the asar, the issue does not occur.
Not clear if the issue lies inside Electron's asar.coffee or the asar implementation itself. It does not appear the asar archive becomes corrupt (as it works fine when you restart) but something is breaking the reading of files.
You basically see something like below, despite the fact that all the files obviously exist:
vendor.js:11 Error: ENOENT, src\resources\units\neutral_beastdarkharbinger.png not found in C:\Users\m\app\v1.0.18\resources\app.asar(…)
vendor.js:11 Error: ENOENT, src\resources\units\neutral_golembloodshard.png not found in C:\Users\m\app\v1.0.18\resources\app.asar(…)
vendor.js:11 Error: ENOENT, src\resources\units\neutral_mechaz0rcannon.png not found in C:\Users\m\app\v1.0.18\resources\app.asar(…)
vendor.js:11 Error: ENOENT, src\resources\units\neutral_chaoselemental.png not found in C:\Users\m\app\v1.0.18\resources\app.asar(…)
vendor.js:11 Error: ENOENT, src\resources\units\neutral_monsteroculus.png not found in C:\Users\m\app\v1.0.18\resources\app.asar(…)
vendor.js:11 Error: ENOENT, src\resources\units\neutral_golem_crossbones.png not found in C:\Users\m\app\v1.0.18\resources\app.asar(…)
vendor.js:11 Error: ENOENT, src\resources\units\neutral_golemstone.png not found in C:\Users\m\app\v1.0.18\resources\app.asar(…)
I can try to write up a standalone test case that reproduces this behavior if necessary.
Just again tested on 33.1 (noting the other bug fix in the asar code) but it still happens.
Activity
cluxter commentedon Sep 22, 2015
I'm having quite the same problem in Windows 7. See here:
https://discuss.atom.io/t/windows-7-dom-shadow-issues-on-v1-0-15/21021/2
zcbenz commentedon Sep 23, 2015
A test case would be awesome, it is quite mysterious to me since the asar code is exactly the same on all platforms.
marwanhilmi commentedon Sep 23, 2015
@zcbenz I'll try wire up a test case that emulates our actual usage but it'll take a little while - I can Skype/Hangout with you and demo you the issue from our actual application. Nonetheless, will try to write up a test case.
Note @cluxter, at first we thought this was an issue with FDs leaking but we do not get EMFILE errors, the files 'disappear' with ENOENT. My experience debugging on Windows is pretty limited but used Sysinternals tools to inspect the open file descriptors and there does not appear to be anything out of the ordinary there.
I'm not sure if Windows has a hard limit on FDs similar to *nix that can configured with
ulimit -n, any ideas on this @zcbenz ?kevinsawicki commentedon Sep 23, 2015
@zcbenz I was just looking at d8d7e5b#diff-ace709cf496d188d302a87b24d26e383R271 which calls
_open_osfhandle.Do those handles returned need to be eventually closed somehow? Could they possibly be leaking when
archive.getFd()occurs a lot and then causingEMFILEerrors to be masked asENOENTissues inside asar?marwanhilmi commentedon Sep 23, 2015
If anyone has suggestions on how to test / count file descriptors on Windows, I can definitely investigate further. From my initial debugging, it was difficult to tell if I had reached a limit (not even really sure how/what this limit is on Windows). It does appear that the asar code will gobble up the errors and just return
ENOENTbut cannot confirm.kevinsawicki commentedon Sep 23, 2015
Okay, I was able to reduce this a bit and reproduce on Windows 8.1 using Electron
0.33.164-bit:Run the following from the dev tools in the default Electron app:
The
ENOENTerrors seems to start after around ~3,000fs.readFileSynccalls.Here is a screenshot showing it working the first time, then trying to call it over and over in loops of 1000 and then it stops working altogether:
Here is the stack trace when it starts happening:
zcbenz commentedon Sep 24, 2015
It is exactly the cause of this bug, great job!
cluxter commentedon Sep 24, 2015
Thanks a lot guys! I hope the v1.0.17 for Windows will be out soon so we can test it. Also the v1.0.16 is not usable on Windows so this is quite important.