Sitelet https://github.com/nodejs/node/issues/41673
Skip to content

Support process.chdir in worker thread #41673

Description

@sindresorhus

What is the problem this feature will solve?

Some test runners like AVA run tests files in separate worker threads, for improved performance and context isolation. It's common in tests to use process.chdir() to change the directory to be able to test how a certain thing works when running from a different place, or maybe you just want it to run in a temporary directory.

What is the feature you are proposing to solve the problem?

I'm aware process.chdir() works per process and not per thread, but maybe it would be possible to expose a process.withCwd(tempDirectory, () => {}) method, where the CWD change is only available inside the given synchronous callback?

What alternatives have you considered?

multi-process model + shared memory. That lets you support SharedArrayBuffer without the headaches of the multi-thread model.

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

    feature requestIssues requesting new Node.js features.processIssues and PRs related to the process subsystem.wontfixIssues that will not be fixed.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