-
Notifications
You must be signed in to change notification settings - Fork 69
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
Move Promise instantiation into memoized function to ensure caching consistency #9927
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
66e78f7
move Promise instantiation into memoized function to ensure caching c…
93cc14e
add changelog entry
0710e79
Merge branch 'develop' into fix/unhandled-promises
timur27 e02ca10
Merge branch 'develop' into fix/unhandled-promises
timur27 90547b9
Merge branch 'develop' into fix/unhandled-promises
timur27 40358a3
Merge branch 'develop' into fix/unhandled-promises
timur27 d4dd4e2
Merge branch 'develop' into fix/unhandled-promises
timur27 2c3797e
Merge branch 'develop' into fix/unhandled-promises
timur27 0d29fe4
Merge branch 'develop' into fix/unhandled-promises
timur27 79853f6
Merge branch 'develop' into fix/unhandled-promises
timur27 8d07b8b
Merge branch 'develop' into fix/unhandled-promises
timur27 df0b214
Merge branch 'develop' into fix/unhandled-promises
timur27 89f30b7
Merge branch 'develop' into fix/unhandled-promises
timur27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: fix | ||
|
||
Fix payment method filtering when billing country changes in Blocks checkout. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
I added the
memoize
to avoid running the verification against Stripe multiple times. But if doing so means we might introduce bugs, maybe it’s best to remove it?Although your fix works well according to my tests, I see that the function wrapped by the promise doesn't get executed again after updating the cart. This isn’t an issue for now since ECE isn't enabled/disabled dynamically (as I know of), but it could become a problem in the future.
I think we can leave it as you’ve proposed in this PR for now, as it seems to be working well.
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.
This is a good point. I was looking at it but haven't included it into this PR. I think that caching itself is a pretty nice addition because otherwise, like you're mentioning, we will be making unnecessary third-party Stripe requests too often.
There is indeed a potential issue because at the moment,
memoize
uses the entirecart
object for cache key generation, which doesn't work well for object comparison and could lead to improper cache hits/misses.By making the cache key more specific with only the relevant fields that affect the payment method availability:
we will ensure it runs on some specific updates. But for this, we'd need to know what fields are relevant in our context, e.g. if billing country change should trigger reviewing ece availability. I think we can open a follow up issue, if we consider this worth diving into further.