Skip to content

Commit 3124ea3

Browse files
KevinVandyAlemTuzlakautofix-ci[bot]
authored
feat: Add built-in retry util into into async utils (#54)
* start on retry feature * add retry example * aborts through async-retryer only * add an optional pacer provider * add providers to main examples * feat: add initial setup for devtools * ci: apply automated fixes * chore: fix test issues * ci: apply automated fixes * chore:fix render issue * ci: apply automated fixes * ci: apply automated fixes * feat: drastically improve the pacer devtools UI * ci: apply automated fixes * chore: remove built-in tree in favor of devtools/ui * ci: apply automated fixes * refactor to key * ci: apply automated fixes * rename devtool packages to be consistent with query devtool package names * fix sherif * separate left and right panels of devtools * denser ui * better right panel, emit entire instance * add some action buttons to devtools that kind of work * event bus goes both ways * all utils listen to devtools * remove console log * ci: apply automated fixes * sync package versions * ci: apply automated fixes * break up devtools components * default options * ci: apply automated fixes * ci: apply automated fixes * package upgrades * update lock file * delete * package upgrades * merge main * clean up retry error tests * ci: apply automated fixes * fix async-throttler stuff * fix retryers with per instance per execution * ci: apply automated fixes * add maxExecutionTime to retryer * add getAbortController apis * add changeset and add retry stuff to guides * generate docs * ci: apply automated fixes * rewrite guides around retries * fix some edge cases on retry error and timeouts * update changelogs and guides * ci: apply automated fixes --------- Co-authored-by: Alem Tuzlak <t.zlak@hotmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent e53439a commit 3124ea3

File tree

224 files changed

+8511
-1264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+8511
-1264
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/react-pacer': minor
3+
---
4+
5+
feat: Added `PacerProvider` component and related hooks (`usePacerContext`, `useDefaultPacerOptions`) for React applications to set default configurations for all pacer utilities within a component tree

.changeset/chubby-laws-smile.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@tanstack/react-pacer-devtools': minor
3+
'@tanstack/solid-pacer-devtools': minor
4+
'@tanstack/pacer-devtools': minor
5+
'@tanstack/react-pacer': minor
6+
'@tanstack/solid-pacer': minor
7+
'@tanstack/pacer': minor
8+
---
9+
10+
- feat:Added `AsyncRetryer` class and `asyncRetry` function with exponential/linear/fixed backoff strategies, jitter support, timeout controls (`maxExecutionTime`, `maxTotalExecutionTime`), lifecycle callbacks (`onRetry`, `onSuccess`, `onError`, `onLastError`, `onSettled`, `onAbort`, `onExecutionTimeout`, `onTotalExecutionTimeout`), dynamic options, and built-in retry integration via `asyncRetryerOptions` for all async utilities (`AsyncBatcher`, `AsyncDebouncer`, `AsyncQueuer`, `AsyncRateLimiter`, `AsyncThrottler`)
11+
- feat: Added `getAbortSignal()` method to all async utilities (`AsyncRetryer`, `AsyncBatcher`, `AsyncDebouncer`, `AsyncQueuer`, `AsyncRateLimiter`, `AsyncThrottler`) to enable true cancellation of underlying async operations (like fetch requests) when `abort()` is called
12+
- feat: Added `asyncBatcherOptions`, `asyncDebouncerOptions`, `asyncQueuerOptions`, `asyncRateLimiterOptions`, `asyncRetryerOptions`, `asyncThrottlerOptions`, `debouncerOptions`, `queuerOptions`, `rateLimiterOptions`, `throttlerOptions` utility functions for sharing common options between different pacer utilities
13+
- fix: Fixed async-throtter trailing edge behavior when long executions were awaited.
14+
- breaking: standardized `reset`, `cancel` and `abort` API behaviors with consistent naming and behavior across all async utilities. Canceling no longer aborts, new dedicated `abort` method is provided for aborting ongoing executions.

docs/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@
8989
{
9090
"label": "Async Batching Guide",
9191
"to": "guides/async-batching"
92+
},
93+
{
94+
"label": "Async Retrying Guide",
95+
"to": "guides/async-retrying"
9296
}
9397
]
9498
},
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
id: PacerProvider
3+
title: PacerProvider
4+
---
5+
6+
<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7+
8+
# Function: PacerProvider()
9+
10+
```ts
11+
function PacerProvider(__namedParameters): Element
12+
```
13+
14+
Defined in: [react-pacer/src/provider/PacerProvider.tsx:44](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/provider/PacerProvider.tsx#L44)
15+
16+
## Parameters
17+
18+
### \_\_namedParameters
19+
20+
[`PacerProviderProps`](../../interfaces/pacerproviderprops.md)
21+
22+
## Returns
23+
24+
`Element`

docs/framework/react/reference/functions/useasyncbatcher.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function useAsyncBatcher<TValue, TSelected>(
1414
selector): ReactAsyncBatcher<TValue, TSelected>
1515
```
1616

17-
Defined in: [react-pacer/src/async-batcher/useAsyncBatcher.ts:167](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-batcher/useAsyncBatcher.ts#L167)
17+
Defined in: [react-pacer/src/async-batcher/useAsyncBatcher.ts:168](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-batcher/useAsyncBatcher.ts#L168)
1818

1919
A React hook that creates an `AsyncBatcher` instance for managing asynchronous batches of items.
2020

docs/framework/react/reference/functions/useasyncdebouncer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function useAsyncDebouncer<TFn, TSelected>(
1414
selector): ReactAsyncDebouncer<TFn, TSelected>
1515
```
1616

17-
Defined in: [react-pacer/src/async-debouncer/useAsyncDebouncer.ts:149](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-debouncer/useAsyncDebouncer.ts#L149)
17+
Defined in: [react-pacer/src/async-debouncer/useAsyncDebouncer.ts:150](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-debouncer/useAsyncDebouncer.ts#L150)
1818

1919
A low-level React hook that creates an `AsyncDebouncer` instance to delay execution of an async function.
2020

docs/framework/react/reference/functions/useasyncqueuer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function useAsyncQueuer<TValue, TSelected>(
1414
selector): ReactAsyncQueuer<TValue, TSelected>
1515
```
1616

17-
Defined in: [react-pacer/src/async-queuer/useAsyncQueuer.ts:167](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-queuer/useAsyncQueuer.ts#L167)
17+
Defined in: [react-pacer/src/async-queuer/useAsyncQueuer.ts:168](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-queuer/useAsyncQueuer.ts#L168)
1818

1919
A lower-level React hook that creates an `AsyncQueuer` instance for managing an async queue of items.
2020

docs/framework/react/reference/functions/useasyncratelimiter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function useAsyncRateLimiter<TFn, TSelected>(
1414
selector): ReactAsyncRateLimiter<TFn, TSelected>
1515
```
1616

17-
Defined in: [react-pacer/src/async-rate-limiter/useAsyncRateLimiter.ts:178](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-rate-limiter/useAsyncRateLimiter.ts#L178)
17+
Defined in: [react-pacer/src/async-rate-limiter/useAsyncRateLimiter.ts:179](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-rate-limiter/useAsyncRateLimiter.ts#L179)
1818

1919
A low-level React hook that creates an `AsyncRateLimiter` instance to limit how many times an async function can execute within a time window.
2020

docs/framework/react/reference/functions/useasyncthrottler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function useAsyncThrottler<TFn, TSelected>(
1414
selector): ReactAsyncThrottler<TFn, TSelected>
1515
```
1616

17-
Defined in: [react-pacer/src/async-throttler/useAsyncThrottler.ts:160](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-throttler/useAsyncThrottler.ts#L160)
17+
Defined in: [react-pacer/src/async-throttler/useAsyncThrottler.ts:161](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/async-throttler/useAsyncThrottler.ts#L161)
1818

1919
A low-level React hook that creates an `AsyncThrottler` instance to limit how often an async function can execute.
2020

docs/framework/react/reference/functions/usebatcher.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function useBatcher<TValue, TSelected>(
1414
selector): ReactBatcher<TValue, TSelected>
1515
```
1616

17-
Defined in: [react-pacer/src/batcher/useBatcher.ts:121](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/batcher/useBatcher.ts#L121)
17+
Defined in: [react-pacer/src/batcher/useBatcher.ts:122](https://github.com/TanStack/pacer/blob/main/packages/react-pacer/src/batcher/useBatcher.ts#L122)
1818

1919
A React hook that creates and manages a Batcher instance.
2020

0 commit comments

Comments
 (0)