Skip to content
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 auto fetching of "latestVersion" configuration from amphtml repo #1273

Merged
merged 7 commits into from
Jan 11, 2022

Conversation

erwinmombay
Copy link
Member

@erwinmombay erwinmombay commented Jan 4, 2022

the previous fix which assumed that the highest version of an extension should be automatically used by the auto importer is incorrect. for example on some instances the newest version is not yet in stable and should not be used.

We fetch the frozen latest version configuration and merge it to generate an "extensionConfig.json" with a "latestVersion" field

@erwinmombay
Copy link
Member Author

@sebastianbenz what is the different between fetchRuntimeParameters and downloadRuntimeParameters? i wasn't sure if i should make this same change to fetchRuntimeParameters

@erwinmombay erwinmombay force-pushed the fix-auto-importer branch 2 times, most recently from bf41d59 to 42cc87d Compare January 7, 2022 18:47
Copy link
Collaborator

@sebastianbenz sebastianbenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing! One nit, otherwise looks good.

throw new Error(`Failed downloading ${extensionConfigUrl} with status ${response.status}`);
const latestVersionsUrl = `https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/compile/bundles.legacy-latest-versions.jsonc`;

const configResponse = await fetch(extensionConfigUrl);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we parallelize the two requests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. ill make the change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

// We add back the "latestVersion" field so that the auto importer
// code knows what "stable" version of the extension to use.
extensionConfig.forEach((entry) => {
entry['latestVersion'] = latestVersionsConfig[entry.name];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

const response = await fetch(extensionConfigUrl);
if (!response.ok) {
throw new Error(`Failed downloading ${extensionConfigUrl} with status ${response.status}`);
const latestVersionsUrl = `https://raw.githubusercontent.com/ampproject/amphtml/main/build-system/compile/bundles.legacy-latest-versions.jsonc`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I've essentially taken this same approach in ampproject/amp-wp#6803.

@erwinmombay erwinmombay merged commit 6f62e73 into ampproject:main Jan 11, 2022
erwinmombay added a commit to erwinmombay/amp-toolbox that referenced this pull request Jan 12, 2022
This is no longer needed as the ampproject#1273
brings back the "latestVersion" in the configuration
sebastianbenz pushed a commit that referenced this pull request Jan 12, 2022
* remove the latestVersion fix

This is no longer needed as the #1273
brings back the "latestVersion" in the configuration

* Revert "Fix: add latest version at runtime"

This reverts commit be439e7.

* lint fix

* run `npm run build`
sebastianbenz added a commit that referenced this pull request Jan 14, 2022
This is no longer needed as the [#1273](#1273) brings back the "latestVersion" in the configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants