Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃挕 Can executing 'Deno. cwd()' in the worker return an independent directory? #24347

Closed
hanrea opened this issue Jun 26, 2024 · 2 comments
Closed
Labels
question a question about the use of Deno

Comments

@hanrea
Copy link

hanrea commented Jun 26, 2024

I want an independent environment for executing workers. I currently treat workers as a lightweight container and hope that each worker has their own directory to handle certain tasks in conjunction with Deno's permission management.
In short, can the program customize the context of the worker.

@dsherret
Copy link
Member

Deno.cwd() returns the current working directory of the process. Workers run in threads within that process, so no.

You'd have to create another api for the workers to use that could have its own local state for the cwd, or you'd need to or change the Deno global in the worker.

@dsherret dsherret added the question a question about the use of Deno label Jun 26, 2024
@hanrea
Copy link
Author

hanrea commented Jun 30, 2024

I have solved this problem, and when initializing the runtime, the worker can write the proxy state parameter:

state.put(options.fs);

When calling op_fs_cwd, it is possible to return diffent values based on the state parameter

@hanrea hanrea closed this as completed Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question a question about the use of Deno
Projects
None yet
Development

No branches or pull requests

2 participants