Skip to content

[fix] Setting job-specific worker option 'env' causes crash #171

@unc0ded

Description

@unc0ded

Describe the bug

  • Node.js version: 17.5
  • OS & version: Windows 11 x64

Actual behavior

Setting a job-specific worker.env field to SHARE_ENV causes nodejs to crash with a DOMException [DataCloneError]: Symbol(nodejs.worker_threads.SHARE_ENV) could not be cloned.

Expected behavior

No exception should be encountered, as the worker.env field should not be cloned into the worker thread, unlike worker.workerData.
The problematic piece of code can be found here at line 310, where the job object is directly added to workerData, which means that the symbol SHARE_ENV will be tried to be cloned into the worker thread, causing an exception.

Code to reproduce

jobs: [
    {
        name: 'test',
        interval: '25d',
        timeout: 0,
        worker: {
            env: SHARE_ENV
        }
    }
]

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Bree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions