Skip to content

Worker instantiation from URLs #30780

Description

@guybedford

When creating workers from within modules, we don't have __filename or __dirname so rather have to rely on import.meta.url, something like:

import { Worker } from 'worker_threads';
import { fileURLToPath } from 'url';
new Worker(fileURLToPath(import.meta.url));

To avoid the fileURLToPath call being necessary here, should we consider supporting URLs as input into new Worker?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.feature requestIssues requesting new Node.js features.workerIssues and PRs related to the worker_threads module and Worker API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions