Request bulkheading isolates concurrency pressure by limiting how many requests can be in flight at once for a client instance. Extra requests wait in a queue (optional max depth) instead of flooding downstream services.
This is useful when a single dependency gets slow and you want controlled backpressure instead of unbounded fan-out.
For the canonical option/type reference, see api.md -> Bulkhead Plugin.
import { createClient } from '@fetchkit/ffetch'
import { bulkheadPlugin } from '@fetchkit/ffetch/plugins/bulkhead'const client = createClient({
plugins: [
bulkheadPlugin({
maxConcurrent: 10,
maxQueue: 50,
}),
],
})
const response = await client('https://api.example.com/data')const client = createClient({
plugins: [
bulkheadPlugin({
maxConcurrent: 10,
maxQueue: 50,
onReject: (req) => {
console.warn('Bulkhead queue full:', req.url)
},
}),
],
})maxConcurrent: Maximum number of in-flight requests allowed at once. Required.maxQueue: Maximum queued requests waiting for a slot. Optional; defaults to unlimited.onReject: Callback fired when a request is rejected because queue capacity is full.order: Plugin execution order override (default:5).
- Bulkheading is off unless the plugin is installed.
- Requests up to
maxConcurrentrun immediately. - Additional requests wait in FIFO order.
- If
maxQueueis set and queue capacity is reached, new requests are rejected withBulkheadFullError. - Queued requests aborted by the caller are removed from the queue and rejected with
AbortError. - Bulkhead state is observable via client extensions:
client.activeCountclient.queueDepth
maxConcurrent: Required (no default)maxQueue:undefined(unlimited)onReject:undefinedorder:5
- Bulkhead + Dedupe: With defaults, bulkhead (
order: 5) runs before dedupe (order: 10), so queued requests are gated before dedupe can collapse them. If you want dedupe to collapse callers before bulkhead slot acquisition, setbulkheadPlugin({ ..., order: 15 })(or any value above dedupe's order). - Bulkhead + Retries: Each retry attempt reacquires a slot; high retry counts can increase queue pressure.
- Bulkhead + Circuit: Bulkhead controls concurrency while circuit controls failure gating. They address different failure modes and can be combined.