Skip to content

[worker_threads] make JS new Error() copyable across threads #26692

@izelnakri

Description

@izelnakri

node version: v11.11.0

Today I have to normalize errors to send worker thread errors back to main thread:

parentPort.postMessage({ error: normalizeError(error) })

function normalizeError(errorObject) {
  return Object.keys(errorObject)
    .reduce((result, key) => Object.assign(result, { [key] : errorObject[key] }), {});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    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