Improve documentation for Electron 20 sandboxing defaults
Nashorn opened this issue · 1 comments
After upgrading to electron 20.0.0, the render process is now throwing this error:
node:electron/js2c/sandbox_bundle:93 Error: module not found: ./node_modules/@electron/remote
at preloadRequire (node:electron/js2c/sandbox_bundle:93:1386)
at :3:14
at runPreloadScript (node:electron/js2c/sandbox_bundle:93:2213)
at Object. (node:electron/js2c/sandbox_bundle:93:2480)
at ./lib/sandboxed_renderer/init.ts (node:electron/js2c/sandbox_bundle:93:2636)
at webpack_require (node:electron/js2c/sandbox_bundle:1:170)
at node:electron/js2c/sandbox_bundle:1:1242
at _electron_webpack_init (node:electron/js2c/sandbox_bundle:1:1320)
at node:electron/js2c/sandbox_bundle:160:455
Hey @Nashorn
There's already a note for this in the README but I think it could be more clear since renderers are sandboxed by default in Electron 20:
Note: Since this is requiring a module through npm rather than a built-in module, if you're using remote from a sandboxed process, you'll need to configure your bundler appropriately to package the code of @electron/remote in the preload script. Of course, using @electron/remote makes the sandbox much less effective.
As a workaround, turn sandbox:false
in the BrowserWindow constructor webPreferences
const win = new BrowserWindow({
webPreferences: {
sandbox: false
}
})