-
Notifications
You must be signed in to change notification settings - Fork 136
[PROPOSAL] fix: detect that fetch is native #1698
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
Conversation
|
✅ Automated performance checks have passed on commit DetailsPerformance tests 1st run outputNo significative change in performance for tests:
|
|
Note that it is also Explanation of the issue: TanStack/query#9049 Also checking |
|
✅ Automated performance checks have passed on commit DetailsPerformance tests 1st run outputNo significative change in performance for tests:
|
|
✅ Automated performance checks have passed on commit DetailsPerformance tests 1st run outputNo significative change in performance for tests:
|
|
Works as intended on the device I tested. CAVEAT TO NOTE: As we discussed this is not exactly 100% ECMAScript-compliant with what they call "white spaces" and "line terminators" with how browsers COULD be implementing this. Also we saw that some irritating polyfill implementations, including from Lastly, this check fails when running RxPaired because we're monkey-patching We may want to add special characters in RxPaired's fetch implems and in the RxPlayer? Or just not do the RegExp with |
I have update to only check AbortController so we won't have those edge cases. |
|
✅ Automated performance checks have passed on commit DetailsPerformance tests 1st run outputNo significative change in performance for tests:
|
As @peaBerberian noticed, applications can install polyfills that override the fetch method on the window object.
However, in our experience, these polyfill implementations have not been very reliable.
The goal of this PR is to detect whether the fetch method has been polyfilled. If it has been overridden, we fall back to using XHR instead.
This detection uses the toString method, which typically returns [native code] for unmodified native functions.
I'm still unsure whether it's the responsibility of RxPlayer to check for the absence of a polyfill, or if it's up to the application to ensure everything works as expected.