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

Make shopify theme dev more resilient to HTTP errors with the Admin API #4606

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

karreiro
Copy link
Contributor

@karreiro karreiro commented Oct 9, 2024

WHY are these changes introduced?

Related to #4576, #4598, and #4599

Retry requests for some HTTP errors. This PR doesn't propose to refresh the session because we're already refreshing it every 30 minutes, the Admin session token expires in 2 hours, and we're getting a fresh token when we start the session.

WHAT is this pull request doing?

This PR updates the Admin REST API client to retry requests when they encounter certain HTTP errors. The Ruby CLI was more permissive regarding execution abortion, so we're adopting this approach as a middle-term to: fail when errors really happen but also be resilient and retry in some scenarios.

How to test your changes?

  • Run shopify theme push -d
  • Cherry-pick this commit e806941bd7538a0325593da4c02663c599f18e64 in your local CLI (it will trigger an error every time we update a file)
  • Update the layout/theme.liquid file
  • Run shopify theme push -d --verbose
  • Notice the retries happening in the logs

Post-release steps

N/A

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@karreiro karreiro requested review from frandiox and a team October 9, 2024 07:42
Copy link
Contributor

github-actions bot commented Oct 9, 2024

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-inner-loop

Copy link
Contributor

github-actions bot commented Oct 9, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.7% (+0.03% 🔼)
8550/11760
🟡 Branches
69.67% (+0.03% 🔼)
4200/6028
🟡 Functions
71.77% (+0.05% 🔼)
2212/3082
🟡 Lines
73.04% (+0.03% 🔼)
8094/11082

Test suite run success

1943 tests passing in 876 suites.

Report generated by 🧪jest coverage report action from 707b901

@EvilGenius13
Copy link
Contributor

🚀 Thank you! This looks great. I left a quick question about the retry time

Copy link
Contributor

@frandiox frandiox left a comment

Choose a reason for hiding this comment

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

Great! I think the dev server is going to be much more resilient to random errors with this 🎉

@karreiro
Copy link
Contributor Author

karreiro commented Oct 21, 2024

@Shopify/app-inner-loop Could you please review this PR?(this is important to the next minor release, and it seems like the auto-merge is not working). Thank you!

@karreiro karreiro added this pull request to the merge queue Oct 21, 2024
Merged via the queue into main with commit e6f83b6 Oct 21, 2024
37 checks passed
@karreiro karreiro deleted the admin-api-retry branch October 21, 2024 08:59
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