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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make permission prompter thread-local #27161

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

carloslfu
Copy link

While using deno_runtime in multiple threads and trying to use different prompters to manage the permissions independently, I hit a roadblock because PERMISSION_PROMPTER is static. This is an example of how I'm using deno_runtime: https://github.com/carloslfu/tauri-deno-example.

This solution uses the thread_local! macro to make the necessary variables thread-local and adapts the corresponding functions.

This PR addresses #27160.

@CLAassistant
Copy link

CLAassistant commented Nov 29, 2024

CLA assistant check
All committers have signed the CLA.

@carloslfu carloslfu marked this pull request as ready for review November 29, 2024 23:56
Comment on lines +91 to +92
MAYBE_BEFORE_PROMPT_CALLBACK.with(|cb| *cb.lock() = Some(before_callback));
MAYBE_AFTER_PROMPT_CALLBACK.with(|cb| *cb.lock() = Some(after_callback));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now incorrect - if these are thread locals then set_prompt_callback needs to be called in each worker thread spawned - you'd need to update op_create_worker in runtime/ops/worker_host.rs

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! That makes sense. Thanks @bartlomieju!

I'll work on updating worker_host.rs. I have some ideas and will test them to see what works best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants