-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Description
- Electron version:
2.0.0-beta.1
- Operating system: macOS
Expected behavior
Preload script should execute once
Actual behavior
Preload script (and in fact node_bootstrap.js
) is executed twice in the same process but in a different context.
How to reproduce
Struggling to isolate this from the application that is experiencing it but I have narrowed it down to this being kind of expected behavior but with a newly introduced bug in 2.0.x
. Basically when you call loadURL
a renderer process is initially launched pointing at about:blank
. In this process renderer/init.js
is called and then the window navigates to the URL you requested.
For an as yet unknown reason in 2.0.x
the --preload
argument is present on the renderer process when the about:blank
page is loaded causing user code to execute twice in the same process. This is only a problem because native modules can only be loaded once in a given process.
The fix for this would be to revert to original behavior where the --preload
(amongst others) arguments are not sent to the renderer until the users page is loaded. (Don't send them for about:blank
).
I'm currently working on a minimal sample