electron: [Bug]: Electron sandbox_bundle.js script failed to run

Preflight Checklist

Electron Version

16.0.4

What operating system are you using?

Windows

Operating System Version

Windows 11 v. 10.0.22000

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

NOW(State)

  1. I can’t start electron because it will quit after the window created for about 2 seconds.
  2. I can’t load the page successfully, But it is not a problem for electron.

The first, I used electron-reloader to reload the page.

[1209/065626.727:ERROR:registration_protocol_win.cc(106)] CreateFile: 系统找不到指定的文件。 (0x2)
[1209/065626.743:ERROR:registration_protocol_win.cc(106)] CreateFile: 系统找不到指定的文件。 (0x2)
[13616:1209/065627.256:ERROR:CONSOLE(160)] "Electron sandbox_bundle.js script failed to run", source: node:electron/js2c/sandbox_bundle (160)
[13616:1209/065627.257:ERROR:CONSOLE(160)] "TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))", source: node:electron/js2c/sandbox_bundle (160)

Here is my window configuration

{
    width: Math.floor((width * 2) / 3),
    height: Math.floor((height * 2) / 3),
    frame: false,
    webPreferences: {
        contextIsolation: false,
        sandbox: false,
        preload: resolve(__dirname, <string>process.env.PRELOAD_PLACE),
    },
}

and the value of process.env.PRELOAD_PLACE is preload.js in development.

This is my preload.ts, which is going to compile to be preload.js with esbuild

import { ipcRenderer } from 'electron'
window.ipcRenderer = ipcRenderer

Actual Behavior

Start Electron Successfully.

Testcase Gist URL

No response

Additional Information

Project Source: stunning-new

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 21
  • Comments: 62 (6 by maintainers)

Most upvoted comments

For me the message only appears when I install the REACT_DEVELOPER_TOOLS extension with electron-devtools-installer and try to open the devtools.

Hello from 2023 with electron@23.0.0 👋

I’ve just upgraded electron from version 11 to version 17 and now have this same error.

[1] [26800:0202/155118.507:ERROR:CONSOLE(160)] "Electron sandbox_bundle.js script failed to run", source: node:electron/js2c/sandbox_bundle (160) [1] [26800:0202/155118.507:ERROR:CONSOLE(160)] "TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))", source: node:electron/js2c/sandbox_bundle (160)

For me the message only appears when I install the REACT_DEVELOPER_TOOLS extension with electron-devtools-installer and try to open the devtools.

Same for me, testing it on electron 18.2.0 this error only shows up when electron-devtools-installer is used.

Hello from electron 25.0.1 ! any updates ?

Im using electron 18.2.0 without electron-devtools-installer and I still get this error.

This is how Im loading the extension:

app.whenReady().then(async () => { createWindow() await session.defaultSession.loadExtension(reactDevToolsPath)

})

Bump

I’m facing the same error but when trying to install VUEJS3_DEVTOOLS.

if (import.meta.env.DEV) {
    app.whenReady()
        .then(() => import('electron-devtools-installer'))

        // !!!!
        // If I comment the following .then, error doesn't show up
        // !!!!

        .then(({ default: installExtension, VUEJS3_DEVTOOLS }) =>
            installExtension(VUEJS3_DEVTOOLS, {
                loadExtensionOptions: {
                    allowFileAccess: true,
                },
            })
        )
        .catch((e) => console.error('Failed install extension:', e));
}

Then if I try to access VueJS dev tools in the browser window, it freezes and won’t let me do anything.

It’s funny, when I’m using version 17.2.0, I will get such warning. But this warning gone when I use 17.1.0 instead, without any other change. I have confirmed several times that the difference is caused by version. @akaushal123 Could you give 17.1.0 a try?

I can confirm that I don’t get the error on 17.1.0 but do on other versions, including the latest (18.0.1)

Confirm: Electron 18.0.1 also show those warning

In my case, i found it is the plugin electron-devtools-installer cause the error.

Those codes runs before new BrowserWindow(xxxx)

await installExtensions();

const installExtensions = async () => {
  const installer = require('electron-devtools-installer');
  const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
  const extensions = ['REACT_DEVELOPER_TOOLS'];

  return installer
    .default(
      extensions.map((name) => installer[name]),
      forceDownload
    )
    .catch(console.log);
};

bump, same issue with last version of electron

Indeed, still present in Electron 22.x

I get the same in 18.0.4 on macOS, however this appears in the console only after opening the DevTools. With DevTools closed, the “error” does not appear.

However, it’s just a message in the console for me. Everything works otherwise.

I’m not using webPrefences.sandbox but I am still getting the same error. I am using electron v17

[4616:0206/230146.903:ERROR:CONSOLE(160)] "Electron sandbox_bundle.js script failed to run", source: node:electron/js2c/sandbox_bundle (160) [4616:0206/230146.914:ERROR:CONSOLE(160)] "TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))", source: node:electron/js2c/sandbox_bundle (160) [20996:0206/230338.183:ERROR:gpu_init.cc(454)] Passthrough is not supported, GL is disabled, ANGLE is

@7086cmd I am getting the same issue with contextIsolation: true.

bump

It’s funny, when I’m using version 17.2.0, I will get such warning. But this warning gone when I use 17.1.0 instead, without any other change. I have confirmed several times that the difference is caused by version.

@akaushal123 Could you give 17.1.0 a try?

I can confirm that I don’t get the error on 17.1.0 but do on other versions, including the latest (18.0.1)

It’s funny, when I’m using version 17.2.0, I will get such warning. But this warning gone when I use 17.1.0 instead, without any other change. I have confirmed several times that the difference is caused by version.

@akaushal123 Could you give 17.1.0 a try?

front end is no use for solving this problem(((

I’ve just upgraded npm as I noticed your version is newer but it made no difference.

MINGW64 /c/git/electron-sandbox-error-repo (master) $ npm start

electron-sandbox-error@1.0.8 start concurrently “cross-env BROWSER=none yarn react-start” “wait-on http://localhost:3000 && electron .” -k

[0] yarn run v1.22.17 [0] $ react-scripts start [0] (node:8552) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: ‘onAfterSetupMiddleware’ option is deprecated. Please use the ‘setupMiddlewares’ option. [0] (Use node --trace-deprecation ... to show where the warning was created) [0] (node:8552) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: ‘onBeforeSetupMiddleware’ option is deprecated. Please use the ‘setupMiddlewares’ option. [0] Starting the development server… [0] [0] Compiled successfully! [0] [0] You can now view electron-sandbox-error in the browser. [0] [0] Local: http://localhost:3000 [0] On Your Network: http://192.168.10.47:3000 [0] [0] Note that the development build is not optimized. [0] To create a production build, use npm run build. [0] [0] asset static/js/bundle.js 1.43 MiB [emitted] (name: main) 1 related asset [0] asset index.html 2.18 KiB [emitted] [0] asset asset-manifest.json 190 bytes [emitted] [0] runtime modules 28.2 KiB 13 modules [0] modules by path ./node_modules/ 1.33 MiB [0] modules by path ./node_modules/core-js-pure/ 24.8 KiB 53 modules [0] modules by path ./node_modules/webpack-dev-server/client/ 62.1 KiB 12 modules [0] modules by path ./node_modules/webpack/hot/.js 4.4 KiB 4 modules [0] modules by path ./node_modules/react/ 119 KiB 4 modules [0] modules by path ./node_modules/html-entities/lib/.js 115 KiB 4 modules [0] modules by path ./node_modules/scheduler/ 29.4 KiB 4 modules [0] modules by path ./node_modules/@pmmmwh/react-refresh-webpack-plugin/ 9.01 KiB 2 modules [0] modules by path ./node_modules/react-refresh/ 24.1 KiB 2 modules [0] modules by path ./node_modules/react-dom/ 959 KiB 2 modules [0] + 3 modules [0] modules by path ./src/ 3.87 KiB [0] ./src/index.js 1.36 KiB [built] [code generated] [0] ./src/components/App.js 2.51 KiB [built] [code generated] [0] webpack 5.68.0 compiled successfully in 5313 ms [1] [1] app.whenReady [1] [13904:0204/085311.165:ERROR:CONSOLE(160)] “Electron sandbox_bundle.js script failed to run”, source: node:electron/js2c/sandbox_bundle (160) [1] [13904:0204/085311.165:ERROR:CONSOLE(160)] “TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))”, source: node:electron/js2c/sandbox_bundle (160)

I’ve also updated react-scripts.

Btw, contextIsolation is true by default.