Search code examples
node.jselectronworker-thread

In electron app, when I using worker_thread, an exception occurs after using Command+Q to exit the app


My code is very simple:

const { Worker } = require('worker_threads');
let script = `console.log('working...');`;
new Worker(script, { eval: true });

I can see working... output in the console, but when I exit the program with command+q, I see an exception in the console: my-electron-app/node_modules/[email protected]@electron/dist/Electron.app/Contents/MacOS/Electron exited with signal SIGSEGV

When I run with sudo npm start, I also see a popup about Electron quit unexpectedly enter image description here

  • Electron Version: 11.3.0
  • Operating System: macOS 11.2
  • Node: 12.18.3
  • Chrome: 87.0.4280.141

To Reproduce

  1. git clone https://github.com/Vict0r-Chen/electron-worker-threads.git
  2. npm install
  3. npm start | sudo npm start

Solution

  • According to this information, using npm install electron 12.0.0@beta --save-dev to upgrade electron to v12.0.0 can solve this problem.