-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support process.chdir
in worker thread
#41673
Comments
@nodejs/workers |
Currently all So I think the current working directory is typically a process-level concept at an operating system level - it looks like some but not all supported operating systems do support making threads with their own From a quick google-stackoverflow it doesn't look possible with C# threads, Java threads, Python threads, rust threads. |
Doing this in userland (from the Kernel PoV not ours, that is, wrap all API calls to resolve paths and everywhere that can spawn a sub_processes) also seems like a pretty big undertaking with a lot of edge cases. Given the complexity to do this on our side, the fact it's not possible on the OS side in a cross-platform way and lack of availability in other platforms I'm leaning towards -1 but it's entirely possible I'm missing something and I'll wait for more people to weigh in. |
To confirm: there's indeed no good, cross-platform way to do this except manual path wrangling. I suggest closing as wontfix. |
Yeah, it’s unfortunate, but this is mostly just a general limitation when using threads. I’ll close this. |
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 aprocess.withCwd(tempDirectory, () => {})
method, where the CWD change is only available inside the given synchronous callback?What alternatives have you considered?
The text was updated successfully, but these errors were encountered: