This guide is the canonical runbook for operating @fetchkit/ffetch in production.
- Set
timeoutper dependency SLA (avoid using one global value for everything). - Set
retriesconservatively (1-3in most systems). - Decide
throwOnHttpErrorpolicy (truefor strict exception flow,falsefor response-driven handling). - Use a runtime-appropriate
fetchHandlerfor SSR/edge/custom environments.
- Enable
circuitPluginfor external dependencies. - Enable
bulkheadPluginfor dependencies that can saturate under load. - Enable
dedupePluginon bursty read-heavy endpoints. - Enable
hedgePluginonly for safe methods and latency-sensitive paths. - Validate plugin order assumptions when composing multiple plugins.
- Instrument
before/after/onErrorhooks for logs and metrics. - Track request latency (
p50/p95/p99) and error-rate by endpoint. - Track resilience signals: circuit opens, bulkhead queue depth, retry counts.
- Add request correlation IDs in
transformRequest.
Minimum metrics to collect:
- Request count by endpoint/method/status
- Latency histogram (
p50,p95,p99) - Error count by error class (
TimeoutError,CircuitOpenError,NetworkError,RetryLimitError, etc.) - Circuit breaker open events and duration
- Bulkhead
activeCount,queueDepth, rejection count - Retry attempts and eventual success-after-retry rate
- Alert on sustained high error rate for a dependency.
- Alert when circuit remains open beyond expected recovery windows.
- Alert when bulkhead queue remains near capacity.
- Alert when
p99latency regresses significantly from baseline.
- Check downstream dependency health first.
- Confirm
threshold/resetvalues are aligned with failure patterns. - Use fallback/degraded responses at app level while circuit is open.
- Avoid releasing queued traffic all at once during recovery.
- Check bulkhead saturation (
activeCount,queueDepth). - Check retry inflation (too many retries amplifying load).
- If using hedging, verify
delayandmaxHedgesare tuned for current latency distribution.
- Ensure retry strategy honors
Retry-Afterbehavior. - Reduce concurrency (
bulkhead) and hedge aggressiveness. - Add app-level backpressure or queueing upstream.
createClient({
timeout: 10_000,
retries: 2,
plugins: [
circuitPlugin({ threshold: 5, reset: 30_000 }),
bulkheadPlugin({ maxConcurrent: 20, maxQueue: 100 }),
dedupePlugin({ ttl: 30_000 }),
],
})createClient({
timeout: 5_000,
retries: 1,
plugins: [
dedupePlugin({ ttl: 10_000 }),
hedgePlugin({ delay: 75, maxHedges: 1 }),
],
})- api.md for full option and plugin reference
- plugins.md for plugin lifecycle and ordering semantics
- advanced.md for retry, circuit, and operational patterns
- errorhandling.md for exact error behavior