Skip to content

worker_threads does not work correctly in ELECTRON_RUN_AS_NODE mode. #17030

Closed

Description

@chris1201
  • Electron Version
    • 4.0.5 ( run as node: 10.11.0 )
  • Operating System (Platform and Version):
    • Windows 10 (1809)
  • Last known working Electron version (if applicable):
    • N/A

Expected Behavior

>node --experimental-worker app.js
hello from electron as node
hello from main thread
hello from electron as node
hello from worker thread
hello from worker
0

>node -v
v10.11.0

Actual behavior

>electron --experimental-worker app.js
hello from electron as node
hello from main thread

>electron -v
v10.11.0

To Reproduce

[app.js]

console.log("hello from electron as node")
const {
    Worker,
    isMainThread,
    parentPort
} = require('worker_threads');

if (isMainThread) {
    console.log("hello from main thread")
    function createWorker() {
        let worker = new Worker(__filename);
        worker.on('message', (msg) => {
	    console.log(msg);
        });
        worker.on('error', (err) => {
            console.log(err);
        });
        worker.on('exit', (code) => {
            console.log(code);
        });
    }
    createWorker();
} else {
   console.log("hello from worker thread")
   parentPort.postMessage("hello from worker");
}

Activity

  1. welcome commented on Feb 18, 2019

    @welcome

    👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

    To help make it easier for us to investigate your issue, please follow the contributing guidelines.

  2. changed the title [-]worker_threads does not work correctly.[/-] [+]worker_threads does not work correctly under ELECTRON_RUN_AS_NODE[/+] on Feb 18, 2019
  3. changed the title [-]worker_threads does not work correctly under ELECTRON_RUN_AS_NODE[/-] [+]worker_threads does not work correctly in ELECTRON_RUN_AS_NODE mode.[/+] on Feb 18, 2019
  4. tfmeneses commented on Jun 20, 2019

    @tfmeneses

    Hi,

    I've got the same issue. Have any idea how to fix this?

  5. ermod commented on Jul 11, 2019

    @ermod

    I also have this problem on Linux with:

    Electron v5.0.6
    Chromium v73.0.3683.121
    Node v12.0.0
    v8 v7.3.492.27-electron.0
    
  6. codebytere commented on Oct 3, 2019

    @codebytere
    Member

    Closing as duplicate of #18540

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions