Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
7086cmd opened this issue Dec 8, 2021 · 62 comments
Open
3 tasks done

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

7086cmd opened this issue Dec 8, 2021 · 62 comments

Comments

@7086cmd
Copy link

7086cmd commented Dec 8, 2021

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

@rajkrrai
Copy link

image

Facing same issue in electron v16

@NL33
Copy link

NL33 commented Dec 22, 2021

Same issue. Electron 15.3. I'm not seeing any performance changes. Does this issue raise any concerns?

@7086cmd
Copy link
Author

7086cmd commented Jan 1, 2022

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.

@physics515
Copy link

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

@hovancik
Copy link

Btw, contextIsolation is true by default.

@7086cmd
Copy link
Author

7086cmd commented Jan 15, 2022

@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.

@nornagon
Copy link
Member

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.

@kevinelliott
Copy link

Any update here?

@7086cmd
Copy link
Author

7086cmd commented Jan 21, 2022

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.

@JonathanWoodward
Copy link

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)

@JonathanWoodward
Copy link

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.

@JonathanWoodward
Copy link

JonathanWoodward commented Feb 2, 2022

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.

@JonathanWoodward
Copy link

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.

@nornagon
Copy link
Member

nornagon commented Feb 2, 2022

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.

@JonathanWoodward
Copy link

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.

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?

@7086cmd
Copy link
Author

7086cmd commented Feb 4, 2022

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

@7086cmd
Copy link
Author

7086cmd commented Feb 4, 2022

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

btw, electron v17

@JonathanWoodward
Copy link

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

@7086cmd
Copy link
Author

7086cmd commented Feb 4, 2022

Emm... wait a moment... I am cloning the repo made my @nornagon

@7086cmd
Copy link
Author

7086cmd commented Feb 4, 2022

@JonathanWoodward It really doesn't warn any!

@7086cmd
Copy link
Author

7086cmd commented Feb 4, 2022

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

@JonathanWoodward
Copy link

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.

@7086cmd
Copy link
Author

7086cmd commented Feb 4, 2022

same. I start the app via electron public/electron

@7086cmd
Copy link
Author

7086cmd commented Feb 4, 2022

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

@RKStudioTM
Copy link

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

@7086cmd
Copy link
Author

7086cmd commented Feb 5, 2022

No really... I have tried, and it is no use. Only webPrefences.sandbox option effects that.

@akaushal123
Copy link

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

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jan 10, 2023
@eviathan
Copy link

Bump

@Bartel-C8
Copy link

Indeed, still present in Electron 22.x

@mvdbastos
Copy link

I'm having the same problem using electron-react-boilerplate out of the box

Electron Version
20.0.2

What operating system are you using?
Windows

Operating System Version
Windows 10 Version 22H2 (SO Compilation 19045.2364)

What arch are you using?
x64

@github-actions github-actions bot removed the stale label Jan 11, 2023
@treeoflife111
Copy link

bump, same issue with last version of electron

@cloudofgeorge
Copy link

cloudofgeorge commented Jan 17, 2023

The same problem has appeared when I was attempting to update electron from 17 to 22 version

@HarryLit
Copy link

HarryLit commented Mar 7, 2023

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);
};

@valsydev
Copy link

valsydev commented May 2, 2023

Hello from 2023 with electron@23.0.0 👋

@Vn-ChemGio
Copy link

I have same issue,
But when I disable use electron-devtools-installer has not show

@Sectaur
Copy link

Sectaur commented May 29, 2023

Bump

@rylorin
Copy link

rylorin commented Jul 13, 2023

This issue is still present. BTW I am using node v18.16.0

@Chalkin
Copy link

Chalkin commented Jul 26, 2023

Issue is still present with "electron": "^25.2.0",

Issue appears to be caused when loading VUEJS3_DEVTOOLS with electron-devtools-installer

app.whenReady().then(() => {
  createWindow();

  session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
    callback({
      responseHeaders: {
        ...details.responseHeaders,
        'Content-Security-Policy': ['script-src \'self\'']
      }
    })
  })

  app.on('activate', function () {
    // On macOS it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (BrowserWindow.getAllWindows().length === 0) {
      createWindow();
    }
  });

  app.whenReady().then(() => {
    installExtension(VUEJS3_DEVTOOLS)
        .then((name) => console.log(`Added Extension:  ${name}`))
        .catch((err) => console.log('An error occurred: ', err));
  });
}).catch((err) => console.log('An error occurred: ', err));

@sunmd
Copy link

sunmd commented Sep 13, 2023

Same for me, testing it on electron 16.2.8.
This can be solved by setting the corresponding command line switch for Chromium with app.commandLine.appendSwitch("no-sandbox"); as described here
it`s not recommend in production. 😢

@Nantris
Copy link
Contributor

Nantris commented Sep 13, 2023

@sunmd 16.2.8 is ancient and you really shouldn't be using that in production either.

@sunmd
Copy link

sunmd commented Sep 15, 2023

@slapbox Thanks for the tip, i can't update the latest version yet for some reason in the work..

@salimdriai
Copy link

salimdriai commented Dec 5, 2023

Hello from electron 25.0.1 ! any updates ?

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@Flavour86
Copy link

bump

@b5414
Copy link

b5414 commented Mar 11, 2024

electron v29.1.1

both errs from:

import installExtension, {REACT_DEVELOPER_TOOLS} from 'electron-devtools-installer';

// ...
installExtension(REACT_DEVELOPER_TOOLS).then(console.log).catch(console.error);

@b5414
Copy link

b5414 commented Mar 11, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests