fix(client-utils): only call fetch
as a function, not a method
#10671
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes: #XXXX
refs: endojs/endo#31 (comment)
Description
Testing on Brave, the browser's global
fetch
function works when called with itsthis
bound to eitherundefined
or the browser global object, but does not work if itsthis
is bound to something else. The code this PR fixes was misbehaving because it was callingpowers.fetch(...)
, i.e., happening to call it as a method with itsthis
bound to the irrelevantpowers
object.This refactor just expresses the intention of this code, which is just to call the
fetch
function without passing it some object as itsthis
binding. This seems to fix the problem.Not at all addressed by this PR: The fact that this problem happened from a programming patterns that seems correct and would have passed review indicates a deeper hazard. This PR does nothing to mitigate this deeper hazard. It only fixes this case where we fell into the hazard.
Security Considerations
none
Scaling Considerations
none
Documentation Considerations
none, except as needed to address the more general hazard.
Testing Considerations
Only tested
fetch
behavior on Brave. Based on that, proceeding under untested assumption that this refactor will work on all supported browsers.Upgrade Considerations
none