Skip to content

cluster: worker doesn't react on message #39854

@relloccate

Description

@relloccate

Hi there.

I have a problem:
The Worker doesn't react on "message" event from the Primary with: type: "module" enabled in package.json
But the Primary is react on "message" event from the worker

Without type: "module" both works.

win10 x64 (node v14.17.5 and v16.7.0)
Guys, any fixes? Thanks.

Example:

import cluster from 'cluster';

if (cluster.isMaster) {
    const worker = cluster.fork();

    worker.on('message', message => {
        // will log the message
        console.log(message);
    });

    worker.send('From Master');
} else {
    process.on('message', message => {
        // will not log the message
        console.log(message);
    });

    process.send('From Worker');
}

Doesn't work ONLY with enabled node.js imports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clusterIssues and PRs related to the cluster subsystem.esmIssues and PRs related to the ECMAScript Modules implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions