electron: Cannot load content on Windows when sandbox is enabled
If sandbox option is enabled on BrowserWindow, the content isn’t loaded on the window. It happens on only Windows. It works on macOS mojave correctly. Any help?
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 an issue that matches the one I want to file, without success.
Issue Details
- Electron Version:
- 5.0.4
- Operating System:
- Windows 10 (1803)
- Last Known Working Electron version:
- Unknown
Expected Behavior
Content should be loaded
Actual Behavior
No content loaded
To Reproduce
- clone sample app https://github.com/dataich/electron-sandbox-sample
- Run electron app
$ cd electron-sandbox-sample
$ yarn
$ npm start
Additional Information
Y:\github.com\dataich\electron-sandbox-sample (master) (electron-sandbox-sample@1.0.0)
$ npm start
> electron-sandbox-sample@1.0.0 start Y:\github.com\dataich\electron-sandbox-sample
> electron-forge start
√ Checking your system
√ Locating Application
√ Preparing native dependencies
√ Launching Application
{ Error: ERR_FAILED (-2) loading 'file://Y:\github.com\dataich\electron-sandbox-sample\src/index.html'
at rejectAndCleanup (Y:\github.com\dataich\electron-sandbox-sample\node_modules\electron\dist\resources\electron.asar\browser\navigation-controller.js:72:21)
at WebContents.stopLoadingListener (Y:\github.com\dataich\electron-sandbox-sample\node_modules\electron\dist\resources\electron.asar\browser\navigation-controller.js:113:9)
at WebContents.emit (events.js:194:13)
errno: -2,
code: 'ERR_FAILED',
url:
'file://Y:\\github.com\\dataich\\electron-sandbox-sample\\src/index.html' }
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 26 (5 by maintainers)
Commits related to this issue
- fix await `ui.loadURL()` Ref https://github.com/electron/electron/issues/18857#issuecomment-503012296 Ref https://github.com/electron/electron/issues/37123 — committed to filecoin-station/desktop by juliangruber 5 months ago
- fix await `ui.loadURL()` (#1300) Ref https://github.com/electron/electron/issues/18857#issuecomment-503012296 Ref https://github.com/electron/electron/issues/37123 — committed to filecoin-station/desktop by juliangruber 5 months ago
This is killing me. I open a window and receive Error: ERR_FAILED (-2) loading ‘http://localhost:1800/something?key=val’ I made my code retry it, it then works and opens the URl in a window.
After that , net.request(…) also seems to be broken:
net::ERR_FAILED at SimpleURLLoaderWrapper.<anonymous> (electron/js2c/browser_init.js:105:6497) at SimpleURLLoaderWrapper.emit (events.js:315:20)
The URL that causes this error for me is valid when I paste it in a Browser directly.
Electron 11.1.1
Error occurring “electron”: “11.3.0”, on Windows 7 32bit. But it’s not persistent. Also 64bit version is OK. I didn’t tried other on OSs.
But it’s not persistent. Just sometimes open app is fail and got this error.
Error: ERR_FAILED (-2) loading ‘app://./’
Any help?
Update to the above: loading
https://google.comis instant and seems to never fail, same for github and main google docs page. So I’d assume it has something to do with load timeouts, or the fact there is a URL passed as a URL parameter.This happens on our Linux (5.10 - 5.15) machines randomly. Most of the time it loads successfully, but once in a while it fails.
package.json:
background.js:
The code:
I found a nasty hack that solved the problem for us. At one point I noticed that resizing the window forced the app to load the html file, and with that, the app UI.
Then I started adding 1px to the app’s width when creating the window:
and then setting the correct width when the window is ready to show:
I know it doesn’t look good, but it worked.
I am seeing this too, OSX works just fine - windows is the issue.