You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If your environment does not support `AbortSignal.any` (Node.js < 20.6, older browsers), you **must install a polyfill** before using ffetch. See the [compatibility guide](./docs/compatibility.md) for instructions.
164
+
If your environment does not support `AbortSignal.any` (Node.js < 20.6, older browsers), you can still use ffetch by installing an `AbortSignal.any`polyfill. `AbortSignal.timeout` is optional because ffetch includes an internal timeout fallback. See the [compatibility guide](./docs/compatibility.md) for instructions.
165
165
166
166
**Custom fetch support:**
167
167
You can pass any fetch-compatible implementation (native fetch, node-fetch, undici, SvelteKit, Next.js, Nuxt, or a polyfill) via the `fetchHandler` option. This makes ffetch fully compatible with SSR, edge, metaframework environments, custom backends, and test runners.
// attempt: number (starts at 1 for first retry decision)
130
130
// request: Request
131
131
// response: Response | undefined
132
132
// error: unknown
@@ -198,13 +198,14 @@ This is useful for:
198
198
- Implementing custom fallback or degraded mode logic
199
199
- Integrating with dashboards or metrics
200
200
201
-
> **Note:**If the client is not configured with a circuit breaker (`circuit` option omitted), `client.circuitOpen` will always be `false` and the property is inert.
201
+
> **Note:**`client.circuitOpen` is provided by `circuitPlugin`. If that plugin is not installed, this extension is not available on the client.
202
202
203
203
### How it Works
204
204
205
205
- When the number of consecutive failures reaches the `threshold`, the circuit "opens" and all further requests fail fast with a `CircuitOpenError`
206
206
- After the `reset` period (in milliseconds), the circuit "closes" and requests are allowed again
207
207
- If a request succeeds, the failure count resets
208
+
- If `onCircuitOpen` is configured, it runs both when the circuit opens and when requests are blocked while it is already open
Copy file name to clipboardExpand all lines: docs/compatibility.md
+42-39Lines changed: 42 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Prerequisites
4
4
5
-
`ffetch`requires modern AbortSignal APIs, specifically `AbortSignal.timeout`and **AbortSignal.any**. Signal combination requires `AbortSignal.any` (native or polyfill).
5
+
`ffetch`can work without native `AbortSignal.timeout`because it has an internal timeout fallback. Signal combination requires **`AbortSignal.any`** (native or polyfill).
6
6
7
7
## Node.js Support
8
8
@@ -13,7 +13,8 @@
13
13
14
14
### Polyfills for Older Versions
15
15
16
-
For older Node.js versions, you must install a polyfill for both `AbortSignal.timeout` and `AbortSignal.any`:
16
+
For older Node.js versions, you must install a polyfill for `AbortSignal.any`.
17
+
`AbortSignal.timeout` polyfill is optional because `ffetch` has an internal timeout fallback:
`ffetch` does not currently publish a UMD build. Use the ESM build shown above (or import from the package in a bundler/runtime environment).
253
254
254
255
## Framework Integration
255
256
@@ -355,7 +356,7 @@ onUnmounted(() => {
355
356
356
357
### SSR Frameworks: SvelteKit, Next.js, Nuxt
357
358
358
-
For SvelteKit, Next.js, and Nuxt, you must pass the exact fetch instance provided by the framework in your handler or context. This is not the global fetch, and the parameter name may vary (often `fetch`, but check your framework docs).
359
+
For SvelteKit, Next.js, and Nuxt, it is recommended to pass the fetch instance provided by the framework in your handler or context for SSR-safe behavior. The parameter name may vary (often `fetch`, but check your framework docs).
359
360
360
361
**SvelteKit example:**
361
362
@@ -392,7 +393,7 @@ export default async function handler(request) {
392
393
}
393
394
```
394
395
395
-
> Always use the fetch instance provided by the framework in your handler/context, not the global fetch. The parameter name may vary, but it is always context-specific.
396
+
> Recommended: use the fetch instance provided by the framework in handler/context code. ffetch also supports any fetch-compatible implementation and falls back to global fetch when no `fetchHandler` is provided.
396
397
397
398
## Troubleshooting
398
399
@@ -401,7 +402,9 @@ export default async function handler(request) {
401
402
#### "AbortSignal.timeout is not a function"
402
403
403
404
```
404
-
Solution: Add a polyfill forAbortSignal.timeout
405
+
ffetch has an internal fallback, so this is usually non-fatal.
Called when the circuit transitions to open after consecutive failures. Receives the request that triggered the open event.
294
+
Called when the circuit opens after consecutive failures, and also when a request is blocked while the circuit is already open. Receives the request associated with that event.
0 commit comments