-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
feature request: add calling thread ID to loader resolve() context #49472
Comments
Is this something we can start working? Or should we wait for enough opinions? |
#30061 (comment) may be relevant. |
FWIW, I was referring to using I would avoid starting any work until you get some input from the loaders team in case they push back for some reason. |
I feel like there's a misunderstanding here (or I don't really understand the use case). If your application has one main thread and two worker threads, then there are three separate loader threads. With this feature, each loader would receive a different thread ID, but always the same one. |
Maybe there is a misunderstanding then. I was under the impression that once the loaders were moved off thread, there was a single loader thread for the entire application. If that is not the current state, I thought it was at least the goal state based on #47747 (comment). |
Another data point from Slack:
If we will eventually end up with a single hook thread, then it seems like it would be very useful to have the calling |
What is the problem this feature will solve?
Some loaders, such as a mocking loader, should be aware of the thread initiating the operation. For example, it is common for ESM mocking to pass a list of export names to the loader thread, and later resolve those exports on an application thread. If a module is mocked from one application thread, and another thread tries to import the same module, it will be unaware of the export values. The export values themselves cannot be passed between threads because some values, such as function, do not serialize.
What is the feature you are proposing to solve the problem?
The
resolve()
loader hook already has acontext
object, which includes theparentURL
. I am requesting that the thread ID also be included. If the thread ID were in the context, theresolve()
hook could identify the proper mock (or real) implementation to use, depending on the thread.What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: