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/_electron@11.3.0@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

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.