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

[sitecore-jss] GraphQL Client Retry Improvements #1755

Merged
merged 29 commits into from
Mar 13, 2024

Conversation

addy-pathania
Copy link
Contributor

@addy-pathania addy-pathania commented Mar 6, 2024

Description / Motivation

  • Handle additional scenarios, now we are able to handle string error codes. By default the DefaultRetryStrategy handles common error codes like ECONNRESET, ETIMEDOUT and EPROTO but other codes can be configured using the same.
  • retries has now been enabled by default with a default value of 3. It can be disabled for all the services by configuring the env variable i.e GRAPH_QL_SERVICE_RETRIES to 0. We can also disable retries per service by configuring it to 0 inside the service-factory file in the app.
  • [Retry-After] header now falls back to the default delay time when it comes out to be empty.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@addy-pathania addy-pathania requested a review from a team March 6, 2024 23:15
Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

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

Looks nice 👍
Please, take a look at my comments/suggestions below
Some parts can improved/refactored so will be easier to maintain "retries" unit tests moving further

Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

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

Please, review the new comments I left in our discussions

@addy-pathania addy-pathania requested a review from ambrauer March 12, 2024 17:32
@addy-pathania addy-pathania requested a review from ambrauer March 12, 2024 20:45
Copy link
Contributor

@ambrauer ambrauer left a comment

Choose a reason for hiding this comment

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

Looks great 👍Just a couple jsdoc suggestions.

@addy-pathania
Copy link
Contributor Author

@illiakovalenko FYI me and Adam had a discussion about the error type and we decided to revert back to almost similar implementation which we had in the beginning of this PR. We have introduced a GraphQLClientError type which is the intersection of the partial of ClientError and 'code' from NodeJS.ErrorException type. This way we and the user would not have to worry about the type guards or the type checking and can easily implement a custom solution. We can think about implementing our own error types in future when we get rid of the graphql request client.

Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

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

The solution using Partial looks good 👍
Added another comment below, after that feel free to merge

@addy-pathania addy-pathania merged commit 53b548a into dev Mar 13, 2024
1 check passed
@addy-pathania addy-pathania deleted the feature/jss-943-retry-improvements branch March 13, 2024 19:43
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.

3 participants