Skip to content

When worker thread throw an error, main thread recieves exit code 0 instead of 1 #21707

Closed
@ciffelia

Description

@ciffelia
  • Version: v10.6.0
  • Platform:
    • Windows 64-bit
    • Linux 29d0523d5d87 4.9.87-linuxkit-aufs #1 SMP Wed Mar 14 15:12:16 UTC 2018 x86_64 Linux (Alpine Linux on Docker)
    • Linux 30e69b847957 4.9.87-linuxkit-aufs #1 SMP Wed Mar 14 15:12:16 UTC 2018 x86_64 GNU/Linux (Debian on Docker)
  • Subsystem: worker_threads

Reproduction code

const { Worker, isMainThread } = require('worker_threads');

if (isMainThread) {
  const worker = new Worker(__filename);
  worker.on('error', err => {
    console.log(`Worker threw an error: ${err.message}`);
  });
  worker.on('exit', code => {
    console.log(`Worker finished with exit code ${code}`);
  });
} else {
  throw new Error('error!');
}

Expected output

Worker threw an error: error!
Worker finished with exit code 1

Actual output

Worker threw an error: error!
Worker finished with exit code 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.workerIssues and PRs related to Worker support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions