Skip to content

Support process.chdir in worker thread #41673

@sindresorhus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

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