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

Error in debug if platform is never initialized on main thread? #423

Closed
dsherret opened this issue Jan 7, 2024 · 3 comments
Closed

Error in debug if platform is never initialized on main thread? #423

dsherret opened this issue Jan 7, 2024 · 3 comments

Comments

@dsherret
Copy link
Member

dsherret commented Jan 7, 2024

It might be useful to error in debug if the platform is never initialized on the main thread. This will help prevent situations where someone initializes v8 on separate threads without doing it on the main thread once (as in my case dprint/dprint-plugin-prettier#74).

@dsherret dsherret changed the title Error in debug if platform is never initialized? Error in debug if platform is never initialized on main thread? Jan 7, 2024
@bartlomieju
Copy link
Member

bartlomieju commented Jan 7, 2024

I think it makes sense, the question is if we should just print a message, panic or use new_default_unprotected_platform in this case.

The code to check if we're on main thread is:

if thread::current().id() == thread::main().id() {
        println!("Currently on the main thread");
    }

@mmastrac do you have thoughts on this one?

@bartlomieju
Copy link
Member

Related #217 - maybe we should always use "unprotected" platform with #[cfg(test)]?

@bartlomieju
Copy link
Member

Appears this was addressed in ec8cbe2.

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

No branches or pull requests

2 participants