- Electron version: 2.0.0.beta-4
- Operating system: 10.13.3 (17D102)
Expected behavior
When reloading (⌘+R) in BrowserWindow with a preload script, it is expected that preload execute under the same conditions as it did the first time.
Actual behavior
Something seems to change between the first load and subsequent loads, where in some subsequent loads (but never initial load) calls to require('electron').remote.app.getAppPath() and possibly other remote aspects will sometimes throw:
Unable to load preload script: /…/runtime/preload.js
(anonymous) @ /…/Electron.app/Contents/Resources/electron.asar/renderer/init.js:199
Error: Cannot call function 'getAppPath' on missing remote object 1
at throwRPCError (/…/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:143:17)
at EventEmitter.<anonymous> (/…/Electron.app/Contents/Resources/electron.asar/browser/rpc-server.js:354:7)
at emitMany (events.js:147:13)
at EventEmitter.emit (events.js:224:7)
at WebContents.<anonymous> (/…/Electron.app/Contents/Resources/electron.asar/browser/api/web-contents.js:295:13)
at emitTwo (events.js:126:13)
at WebContents.emit (events.js:214:7)
at Object.exception (/…Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:209:30)
at metaToValue (/…/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:213:28)
at Object.remoteMemberFunction (/…/Electron.app/Contents/Resources/electron.asar/renderer/api/remote.js:113:16)
at Object.<anonymous> (/…/runtime/preload.js:29:21)
at Object.<anonymous> (/…/runtime/preload.js:171:3)
at Module._compile (module.js:642:30)
at Object.Module._extensions..js (module.js:653:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:504:12)
at Function.Module._load (module.js:496:3)
How to reproduce
I am assuming simply reloading a window with a preload script that tries to remote.app.getAppPath() would sometimes trigger it on 2.0.0-beta.4 but never (100% confirmed) on 2.0.0-beta.3.
Hopefully you can reproduce it, my current setup will take time to extrapolate a minimal repo (sorry).
Expected behavior
When reloading (⌘+R) in BrowserWindow with a preload script, it is expected that preload execute under the same conditions as it did the first time.
Actual behavior
Something seems to change between the first load and subsequent loads, where in some subsequent loads (but never initial load) calls to
require('electron').remote.app.getAppPath()and possibly other remote aspects will sometimes throw:How to reproduce
I am assuming simply reloading a window with a preload script that tries to
remote.app.getAppPath()would sometimes trigger it on 2.0.0-beta.4 but never (100% confirmed) on 2.0.0-beta.3.Hopefully you can reproduce it, my current setup will take time to extrapolate a minimal repo (sorry).