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

Preventing retries should result in the same result structure as if the retry wasn't used. #4721

Closed

Conversation

LordZardeck
Copy link

@LordZardeck LordZardeck commented Nov 21, 2024

This PR fixes #3789. Originally, by forcing the value of HandledError to be of type {error: any} instead of the full result value, the meta field would be lost. This means there would be no way to fail out of retrying but keep the result consistent as if no retry had happened.

This PR fixes what I believe to be a bug, but could be a breaking change. Alternatives could be to add an additional fail option such as failResult, or by exporting the HandledError class to be manually thrown in whatever fashion the user desires.

Originally, by forcing the value of `HandledError` to be of type `{error: any}` instead of the full result value, the meta field would be lost. This means there would be no way to fail out of retrying but keep the result consistent as if no retry had happened.
Copy link

codesandbox bot commented Nov 21, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit fa36b6c:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

Copy link

netlify bot commented Nov 21, 2024

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit fa36b6c
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/673fb491228bf40008257a94
😎 Deploy Preview https://deploy-preview-4721--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@EskiMojo14
Copy link
Collaborator

This would be a breaking change, yes - as the docs show, the fail utility only expects to be passed the error itself, not the entire result shape.

You could make it non-breaking by changing it back and moving meta to a second parameter: retry.fail(result.error, result.meta)

@markerikson
Copy link
Collaborator

Opted for #4723 instead, thanks!

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.

Return meta from retry.fail()
3 participants