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: retry on all network errors #401

Merged
merged 3 commits into from
Oct 17, 2023

Conversation

NWRichmond
Copy link
Contributor

@NWRichmond NWRichmond commented Oct 16, 2023

Why are these changes introduced?

Addresses ENG-10894

SDK should retry on network errors

The Storefront SDK wasn't retrying on certain network errors like ETIMEDOUT.

What is this pull request doing?

This PR updates the default urql request retry configuration so that retries happen in response to any network error. Previously, retries only happened in response to certain HTTP error statuses. This made it difficult to respond to transient network issues like ETIMEDOUT.

This PR also adds a couple of new unit tests to achieve 100% coverage.

How to Test

End to end

This is a tough PR to test end-to-end. Instead of asking reviewers to follow steps, I'll provide my own testing results.

In a fresh project, I used nock to simulate an ETIMEDOUT error. I then added some logging to the retryIf configuration in node_modules/@nacelle/storefront-sdk/dist/nacelle-storefront-sdk.js. I made a content request and saw that the ETIMEDOUT led to the expected number of retries (5):

storefront sdk demo retry

Unit tests

  1. Check out the ENG-10894/storefront-sdk-retry-on-all-network-errors branch
  2. Navigate to packages/storefront-sdk
  3. npm run build - it should build without errors
  4. npm run coverage - all tests should pass with 100% coverage

Checklist

  • This Pull Request aligns with nacelle-js' Code of Conduct.
  • You can follow your own "How to Test" instructions and get the expected result.
  • Created a changeset (if the change should appear in a changelog).

@changeset-bot
Copy link

changeset-bot bot commented Oct 16, 2023

🦋 Changeset detected

Latest commit: 6e34723

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nacelle-gatsby-reference-store ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 6:03pm
nacelle-gatsby-starter ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 6:03pm
nacelle-next-reference-store ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 6:03pm
nacelle-next-starter ❌ Failed (Inspect) Oct 16, 2023 6:03pm
nacelle-nuxt-reference-store ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2023 6:03pm
nacelle-nuxt-starter ❌ Failed (Inspect) Oct 16, 2023 6:03pm

Copy link
Contributor

@KrisQ KrisQ left a comment

Choose a reason for hiding this comment

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

Looks good!

Screenshot 2023-10-17 at 8 44 15 AM

@NWRichmond NWRichmond merged commit 6f2e5f1 into main Oct 17, 2023
12 of 14 checks passed
@NWRichmond NWRichmond deleted the ENG-10894/storefront-sdk-retry-on-all-network-errors branch October 17, 2023 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants