[Bug]: Electron sandbox_bundle.js script failed to run
Preflight Checklist
- [X] I have read the Contributing Guidelines for this project.
- [X] I agree to follow the Code of Conduct that this project adheres to.
- [X] I have searched the issue tracker for a feature request that matches the one I want to file, without success.
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)
- I can't start
electronbecause it will quit after the window created for about 2 seconds.- 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

Facing same issue in electron v16
Same issue. Electron 15.3. I'm not seeing any performance changes. Does this issue raise any concerns?
Nowadays, I retried it. The value of contextIsolation in my config is true.
Then, It will not show this.
Maybe it is a sandbox without contextIsolation bug. I am not sure about it.
@7086cmd I am getting the same issue with contextIsolation: true.
Btw, contextIsolation is true by default.
@physics515 Context Isolation makes the pre load and the page with different channels, so you must use context bridge to connect from preload script to the page.
Thanks for reporting this and helping to make Electron better!
Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use.
Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.
I'm adding the blocked/need-repro label for this reason. After you make a test case, please link to it in a followup comment.
Thanks in advance! Your help is appreciated.
Any update here?
Okay, I am now available(after the final exam). I will try to make a testcase to show the problem tomorrow. If there is any updates, I will notice here.
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)
After every change in code on the render side I get:
[0] Compiling... [0] Compiled successfully!
Which is as before, the devtools refreshes and errors go away but I can no longer click on anything in the electron window until I restart the application.
I've created a repo for testing.
Using node v16.13.2 on Windows 10.
https://github.com/JonathanWoodward/electron-sandbox-error
yarn install
yarn start
$ yarn start
yarn run v1.22.10
$ concurrently "cross-env BROWSER=none yarn react-start" "wait-on http://localhost:3000 && electron ." -k
[0] $ react-scripts start
[0] i 「wds」: Project is running at http://192.168.10.47/
[0] i 「wds」: webpack output is served from
[0] i 「wds」: Content not from webpack is served from C:\git\electron-sandbox-error-repo\public
[0] i 「wds」: 404s will fallback to /
[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 yarn build.
[0]
[1]
[1] app.whenReady
[1] [868:0202/173923.237:ERROR:CONSOLE(160)] "Electron sandbox_bundle.js script failed to run", source: node:electron/js2c/sandbox_bundle (160)
[1] [868:0202/173923.237:ERROR:CONSOLE(160)] "TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))", source: node:electron/js2c/sandbox_bundle (160)
The sandbox error will show after the devtools load.
Go into App.js and edit the test inside h1 tag. After this you can no longer click on a button.
I've created a repo for testing.
Using node v16.13.2 on Windows 10.
https://github.com/JonathanWoodward/electron-sandbox-error
yarn install
yarn start
$ yarn start yarn run v1.22.10 $ concurrently "cross-env BROWSER=none yarn react-start" "wait-on http://localhost:3000 && electron ." -k [0] $ react-scripts start [0] i 「wds」: Project is running at http://192.168.10.47/ [0] i 「wds」: webpack output is served from [0] i 「wds」: Content not from webpack is served from C:\git\electron-sandbox-error-repo\public [0] i 「wds」: 404s will fallback to / [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 yarn build. [0] [1] [1] app.whenReady [1] [868:0202/173923.237:ERROR:CONSOLE(160)] "Electron sandbox_bundle.js script failed to run", source: node:electron/js2c/sandbox_bundle (160) [1] [868:0202/173923.237:ERROR:CONSOLE(160)] "TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))", source: node:electron/js2c/sandbox_bundle (160)The sandbox error will show after the devtools load.
Go into App.js and edit the test inside h1 tag. After this you can no longer click on a button.
Okay, the reloading issue seems to be react-scripts version but the sandbox error still stands.
Hm, I can't reproduce the sandbox error using https://github.com/JonathanWoodward/electron-sandbox-error. I cloned, ran yarn to install dependencies, then yarn start, but I see no error being printed.
Hm, I can't reproduce the sandbox error using https://github.com/JonathanWoodward/electron-sandbox-error. I cloned, ran
yarnto install dependencies, thenyarn start, but I see no error being printed.
It occurs for me on several developers machines. What version of nodejs, yarn, npm, windows are you using? Maybe there is another global packaged involved?
Yes... It always has this alert..? What's the platform of you(? @nornagon @JonathanWoodward My Platform:
System:
OS: Windows 10 10.0.22000
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Memory: 2.83 GB / 15.92 GB
Binaries:
Node: 17.2.0 - C:\Program Files\nodejs\node.EXE
npm: 8.1.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22000.120.0), Chromium (97.0.1072.76)
Internet Explorer: 11.0.22000.120
run this:
npx envinfo --system --npmPackages '{electron}' --binaries --browsers
Yes... It always has this alert..? What's the platform of you(? @nornagon @JonathanWoodward My Platform:
System: OS: Windows 10 10.0.22000 CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz Memory: 2.83 GB / 15.92 GB Binaries: Node: 17.2.0 - C:\Program Files\nodejs\node.EXE npm: 8.1.4 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.22000.120.0), Chromium (97.0.1072.76) Internet Explorer: 11.0.22000.120run this:
npx envinfo --system --npmPackages '{electron}' --binaries --browsers
btw, electron v17
npx envinfo --system --npmPackages '{electron}' --binaries --browsers
System: OS: Windows 10 10.0.19043 CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor Memory: 16.77 GB / 31.93 GB Binaries: Node: 16.13.2 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD npm: 7.20.6 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.19041.1266.0), Chromium (97.0.1072.76) Internet Explorer: 11.0.19041.1202
Emm... wait a moment... I am cloning the repo made my @nornagon
@JonathanWoodward It really doesn't warn any!
Oh....
When I turn on webPrefences.sandbox true, it will show:
[21044:0204/164608.614:ERROR:cache_util_win.cc(20)] Unable to move the cache: 拒绝访问。 (0x5)
[21044:0204/164608.658:ERROR:cache_util.cc(144)] Unable to move cache folder C:\Users\Mike\AppData\Roaming\Electron\GPUCache to C:\Users\Mike\AppData\Roaming\Electron\old_GPUCache_000
[21044:0204/164608.660:ERROR:disk_cache.cc(185)] Unable to create cache
[21044:0204/164608.660:ERROR:shader_disk_cache.cc(612)] Shader Cache Creation failed: -2
[21044:0204/164611.978:ERROR:service_worker_storage.cc(1899)] Failed to delete the database: Database IO error
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
[email protected] 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.
same. I start the app via electron public/electron
front end is no use for solving this problem(((
What it could be is your calling a function on the Browser Window before the Browser is actually loaded or shown thus it calling the Error
No really... I have tried, and it is no use. Only webPrefences.sandbox option effects that.
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
I'm not using
webPrefences.sandboxbut 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
You might did something to turn on the sandbox. It must be a bug in sandbox, I think.
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?
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?
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
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.
Yes. It shows the error without any crash when running.
@DCzajkowski I have the same behavior
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.
Yes,I have also noticed that the warning appears only when I open devtools in the main process.
For me the message only appears when I install the REACT_DEVELOPER_TOOLS extension with electron-devtools-installer and try to open the devtools.
I also started seeing this above 17.1.0. I can't find anything that's broken as a result of these errors though?
Indeed it only occurs when opening devtools, or when navigating to the React devtools tabs for the first time.
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.
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)
})
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.