Skip to content

Conversation

@faizanu94
Copy link

Resolves #503

Summary

This PR adds support for retryCondition option for $fetch.

What’s new

  • Introduces retryCondition(context) callback for custom retry logic.
  • Keeps retryStatusCodes and retryCondition independent — retries if either is satisfied.
  • If retryCondition throws, the error is propagated to the consumer.
  • Functionality is verified via unit tests

Example

await $fetch('/api/data', {
  retry: 3,
  retryCondition: (ctx) => {
    // Retry until response body contains expected field
    return ctx.response?._data?.status !== 'ready';
  }
});

@faizanu94 faizanu94 mentioned this pull request Sep 19, 2025
1 task
@onmax
Copy link

onmax commented Oct 12, 2025

proposal: rename it to retryIf

@faizanu94 faizanu94 changed the title Add retryCondition Option Add retryIf Option Oct 13, 2025
@faizanu94
Copy link
Author

Agreed, renamed to retryIf ✅ aligns with predicate style naming

@faizanu94
Copy link
Author

@pi0 this is ready for review when you get a moment!

@faizanu94 faizanu94 force-pushed the feat/retry-condition branch 3 times, most recently from ad22b48 to 5993edb Compare November 17, 2025 22:14
@faizanu94 faizanu94 force-pushed the feat/retry-condition branch from cbba814 to a8d70ab Compare November 17, 2025 22:25
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.

Custom retry logic

2 participants