-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
✨ Allow Geo information in url rewriting #35558
✨ Allow Geo information in url rewriting #35558
Conversation
}, 'AMP_GEO'); | ||
} | ||
) | ||
(geoType) => geoData(this.cachedGeo_, geoType), |
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'm not too familiar with url-replacements
, but isn't this a race condition? Is it fine to default to unknown
before amp-geo service finishes loading?
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.
Yes, it's a race condition, but intentionally.
We opt to not interfering with delays when a user clicks on a link targetted by replacement by waiting for async data. If the data is not present for sync access here, a default fallback value is used.
Likely, if we do this, it will need some additional documentation.
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.
Apologies if this is a silly question, but why does it need to be sync? Why can't the URL resolve async?
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.
If the value is async, then users have to wait during a click event to start a navigation to the next document.
(I think we could also rewrite async items greedily as an alternative, but this isn't supported right now)
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.
Thank you for writing tests!
We should also update documentation in https://github.com/ampproject/amphtml/blob/main/extensions/amp-link-rewriter/amp-link-rewriter.md#output-required.
Approving to unblock / since I'm not sure if you want to address that separately
SGTM, I'll make the documentation change following this PR landing. |
Addresses #35482.
This isn't fully ready for merging (no tests!), but wanted feedback on the approach.Now ready for review, including a test for the sync behaviour from a cached value.
This PR will likely need additional documentation to demonstrate the inherent race condition with requesting geo information to be available for a sync action.