Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@fortify-ts/bulkhead

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fortify-ts/bulkhead

Concurrency limiter bulkhead pattern for @fortify-ts

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

@fortify-ts/bulkhead

Bulkhead (concurrency limiter) pattern for the Fortify-TS resilience library.

Installation

npm install @fortify-ts/bulkhead
# or
pnpm add @fortify-ts/bulkhead

Features

  • Concurrency Limiting: Control maximum parallel executions
  • Request Queueing: Queue excess requests with optional timeout
  • Rejection Handling: Reject when at capacity
  • Metrics: Track active and queued requests

Usage

Basic Usage

import { Bulkhead } from '@fortify-ts/bulkhead';

const bulkhead = new Bulkhead<Response>({
  maxConcurrent: 10,
});

try {
  const result = await bulkhead.execute(async (signal) => {
    return fetch('/api/data', { signal });
  });
} catch (error) {
  if (error instanceof BulkheadFullError) {
    console.log('Too many concurrent requests');
  }
}

With Queueing

const bulkhead = new Bulkhead<Response>({
  maxConcurrent: 10,
  maxQueue: 100,        // Queue up to 100 requests
  queueTimeout: 5000,   // 5 second queue timeout
});

Configuration Options

const bulkhead = new Bulkhead<Response>({
  // Maximum concurrent executions
  maxConcurrent: 10,

  // Maximum queued requests (0 = no queue)
  maxQueue: 100,

  // Queue timeout in milliseconds
  queueTimeout: 5000,

  // Rejection callback
  onRejected: (activeCount, queuedCount) => {
    console.log(`Rejected: ${activeCount} active, ${queuedCount} queued`);
  },

  // Optional logger
  logger: myLogger,
});

Checking Status

// Get current counts
const activeCount = bulkhead.getActiveCount();
const queuedCount = bulkhead.getQueuedCount();

// Check if at capacity
const isFull = activeCount >= config.maxConcurrent;

Resource Cleanup

// Close bulkhead (rejects queued requests)
await bulkhead.close();

Configuration Reference

OptionTypeDefaultDescription
maxConcurrentnumber10Max parallel executions
maxQueuenumber0Max queued requests
queueTimeoutnumber-Queue timeout (ms)
onRejectedfunction-Rejection callback
loggerFortifyLogger-Optional logger

Error Types

ErrorDescription
BulkheadFullErrorBulkhead and queue at capacity
BulkheadClosedErrorBulkhead has been closed

License

MIT

Keywords

bulkhead

FAQs

Package last updated on 23 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts