-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix fetching assets in Web Workers #12134
Conversation
The logic in this PR was borrowed from gloo-net and essentially probes the global Javascript context to see if we are in a window or a worker before calling `fetch_with_str`.
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
Not sure what the procedure/rules are here, but I would like to suggest that this be added to the 0.13.1 milestone. |
unblocks your use case, not a breaking change, and it works 👍 |
@mockersf do I need to rebase this PR onto the release-0.13.1 branch? |
no, once this PR has been approved by someone else, we'll merge it to main then cherry pick to the release branch |
…_sys::WorkerGlobalScope` using bindings instead of `js_sys::Reflect`.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To reduce the amount of FFI calls you could cache the current global context in a thread_local
. Keep in mind that this might or might not be worth it considering we are doing a HTTP request here.
Otherwise LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch and a simple fix! I've just added some comments as a suggestion to help explain some of the JS weirdness, and link back to MDN documentation as well.
Co-authored-by: Zachary Harrold <[email protected]>
# Objective This PR fixes #12125 ## Solution The logic in this PR was borrowed from gloo-net and essentially probes the global Javascript context to see if we are in a window or a worker before calling `fetch_with_str`. --------- Co-authored-by: Zachary Harrold <[email protected]>
Objective
This PR fixes #12125
Solution
The logic in this PR was borrowed from gloo-net and essentially probes the global Javascript context to see if we are in a window or a worker before calling
fetch_with_str
.