You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of v12.0.2, there were issue with asar file fd handling on Windows.
The file would be kept open by the main process once used, and no way to close it.
#28195 was previously submitted, but NOT resolved by #28137.
Maybe It's time to provide a public API to manage asar files.
In my scenario, ASAR files was to be used as plugin packages, thus needs to be replaced or removed when process is still running.
It seems ok to do it on macOS , but not on Windows.
I guess some of asar related code is to be refactored, so please consider this proposal.
I'm using macOS and electron v11.4.1. Found that if the renderer window load some resources(image, for example) which located in the asar bundle, the main process will keep file descriptors of the asar file, and it seems it will never be disposed. Whille using, the asar file descriptors opened by the main process will be more and more.
This should be solved, the leak of the asar file descriptors might be a problem.
I currently walk around this issue by overriding the file protocol handler.
Then fetch and return contents of asar through my own pure javascript asar IO implementation.
@nomagick can you please share how to do the overriding? I'm trying to configure electron-builder to exclude the modules which holding images from asar bundle, but still be able to require the module as usual. Seems no luck currently 😢
However the main app.asar file is more special because browser process node.js load resources from it too.
So it's not likely that the main app.asar could be modified while running.
If you are trying to achieve update by swaping app.asar, that probably will not work.
Maybe a solution is to leave your images in the app.asar.unpacked folder. You can achieve this by specify --unpack-dir to the asar pack command. It will then just leave store them in the app.asar.unpacked folder - that will be logically merged with your regular asar folder.
I had to do this will native modules and binary executables, which also have problems when loaded from asar.
Activity
aprilandjan commentedon May 18, 2021
I'm using macOS and electron v11.4.1. Found that if the renderer window load some resources(image, for example) which located in the asar bundle, the main process will keep file descriptors of the asar file, and it seems it will never be disposed. Whille using, the asar file descriptors opened by the main process will be more and more.
This should be solved, the leak of the asar file descriptors might be a problem.
nomagick commentedon May 18, 2021
I currently walk around this issue by overriding the file protocol handler.
Then fetch and return contents of asar through my own pure javascript asar IO implementation.
aprilandjan commentedon May 18, 2021
@nomagick can you please share how to do the
overriding? I'm trying to configureelectron-builderto exclude the modules which holding images from asar bundle, but still be able to require the module as usual. Seems no luck currently 😢nomagick commentedon May 19, 2021
@aprilandjan https://www.electronjs.org/docs/api/protocol#protocolinterceptfileprotocolscheme-handler
However the main app.asar file is more special because browser process node.js load resources from it too.
So it's not likely that the main app.asar could be modified while running.
If you are trying to achieve update by swaping app.asar, that probably will not work.
aprilandjan commentedon May 19, 2021
@nomagick thanks for your advise, I'll try the protocol api 🙏
gpetrov commentedon May 19, 2021
Maybe a solution is to leave your images in the
app.asar.unpackedfolder. You can achieve this by specify--unpack-dirto theasar packcommand. It will then just leave store them in theapp.asar.unpackedfolder - that will be logically merged with your regular asar folder.I had to do this will native modules and binary executables, which also have problems when loaded from asar.