-
Notifications
You must be signed in to change notification settings - Fork 128
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: use wrapper to allow patching global fetch
#377
Conversation
nuxt/test-utils#775 just mentioning this one here, thanks for taking this up! |
fetch
Thanks for PR. I was thinking of same solution too. I agree it is needed but (sadly) means 1) we allow patching behavior of a standard primitive 2) adds small call overhead. @dwightjack Have you tried this solution btw? I guess we might need to patch the node entrypoint as well. (also in |
Oh, I missed that part. I updated the PR (4026829). I wasn't able to make a full reproduction of Nuxt + MSW on StackBlitz (I guess there are some problems with service workers), so I pushed it to a GitHub repository: https://github.com/dwightjack/ofetch-msw-reproduction Some notes:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #377 +/- ##
===========================================
+ Coverage 56.86% 67.08% +10.22%
===========================================
Files 16 16
Lines 728 474 -254
Branches 113 116 +3
===========================================
- Hits 414 318 -96
+ Misses 303 146 -157
+ Partials 11 10 -1 β View full report in Codecov by Sentry. |
I'm working to add some CF Pages support to I think the work being done here would unblock this use-case too! |
Related nuxt/nuxt#24519 |
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.
Thanks β€οΈ
Test for pageload. Tests for distributed tracing for navigations are still coming (waiting for next Nuxt version which includes the new version of ofetch with [this PR](unjs/ofetch#377))
π Linked issue
#295
β Type of change
π Description
I was investigating the usage of MSW on Nuxt 3 and encountered #295. Looking at the source code, I think that a possible solution is to define the local
fetch
constant as getter instead of a reference toglobalThils.fetch
. In this way, 3rd party library can patch and overwrite the global object without us referencing an outdated function:At the moment, I cannot think of possible breaking changes or side effects caused by this change, but I might miss something.
π Checklist