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(xsfetch): make retry work, remove the exposure of retryCount #88

Merged
merged 2 commits into from
Mar 4, 2025

Conversation

junkwarrior87
Copy link
Contributor

Hi, I've found an issue in xsfetch that retry does not take effect.
Essentially it's options.retry < options.retryCount needs to be options.retry > options.retryCount.

It can be easily reproduced by the following code (you might add some debug logs in the retry logic to see that it is not executed):

import { createFetch } from 'xsfetch';

const fetch = createFetch({
  retry: 3,
  retryDelay: 1000,
  retryStatusCodes: [404],
});

fetch('https://jsonplaceholder.typicode.com/todos/500')
  .then(console.log, console.error);

This PR is fixing the issue and also performing a little bit refactoring that eliminates the need for exposing retryCount in the fetch options.

@kwaa
Copy link
Member

kwaa commented Mar 4, 2025

Thanks for the contribution! I'll merge after fixing the lint error.

@kwaa kwaa added the bug Something isn't working label Mar 4, 2025
@kwaa kwaa merged commit 2d02890 into moeru-ai:main Mar 4, 2025
1 check passed
@junkwarrior87 junkwarrior87 deleted the xsfetch branch March 4, 2025 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants