async-bulkhead-llm - v3.19.1
    Preparing search index...

    Migration

    Every release since v2 has been additive at the call site. The notes below cover what changes if you assert exact object shapes.

    For the full per-release record, see the changelog.

    The minimum Node.js version is now 22. Node.js 20 reached end-of-life on 2026-04-30 and is no longer tested. With engine-strict set, npm refuses to install 3.19 on Node.js 20; otherwise it warns.

    No call-site changes are required and the API surface is unchanged. Two results differ, for code that asserts exact token numbers or waits on drain():

    • A progressive reportUsage() whose remainingOutputTokens + safetyMarginTokens exceeds the call's reservation now holds the reservation, not the sum. UsageReport.held, the usage event's heldTokens and deltaTokens, inFlightTokens, and totalOverrun no longer include the excess, and the excess no longer triggers an overrun stop. The event's safetyMarginTokens is still the value you passed.
    • A drain() that was waiting while calls were queued behind maxConcurrent: 0 now resolves when the last of those calls times out or is aborted. It used to stay pending although the bulkhead was idle.

    No call-site changes are required, and nothing is stopped unless you opt in. Without a stop policy and without stopOnTimeout, results, stats, events, and the signal handed to a run() callback are what they were in 3.17.

    The additive surface, for code that asserts exact shapes or switches exhaustively:

    • LLMAdmissionLimits gains optional stop. limits(), stats().limits, and the reconfigure event include it only while a policy is applied.
    • LLMEventType gains stop.
    • stats().llm gains stopped and stoppedByCause, and each class gains stopped. All three are absent until the bulkhead's first stop.
    • UsageReport gains stopped: true once an admission was stopped.
    • drain() accepts stopOnTimeout, and its result gains stopped only when that option was passed.
    • LLMAdmissionStoppedError is a new export. LLMAdmissionStopCause and LLMAdmissionStopPolicy are new type exports.

    If you opt in, three things are worth knowing up front:

    • The policy is part of the snapshot and is not inherited. A later applyLimits() without stop turns stopping off. setBudget() carries the policy along.
    • While a policy is applied, newly admitted run() callbacks receive a signal owned by the engine instead of the caller's own signal object (or instead of undefined). The caller's abort is forwarded to it. Code that compares signal identity inside the callback will see a different object.
    • LLMAdmissionStoppedError is not an LLMBulkheadRejectedError. A handler that maps every other error to an upstream failure will misreport stops until it handles the new error.

    No existing admission call-site changes are required. Successful admission results, tokens, run contexts, and admit / release events gain immutable resources. Stats gain active-LLM and borrowed-concurrency-abandon counters (including a borrowedConcurrencyAbandonedByCause split), and LLMEventType gains borrowedConcurrencyAbandon; exhaustive shape and event switches should account for these additive fields. Listener and LLMBorrowedConcurrencyAbandonCause are new entry-point type exports.

    Use borrowedConcurrencyDeadlineMs only for a wall-clock lease on class concurrency borrowed from shared capacity. Expiry now has its own LLMBorrowedConcurrencyDeadlineError; it is not an admission rejection. The local slot returns immediately, while the token hold and drain() remain live until the callback settles. This does not prove remote provider reclamation.

    That split lifecycle is observable in shutdown behavior. After abandonBorrowedConcurrency(), drain() without timeoutMs waits for the matching token settlement even though base concurrency is already available. A manual acquire() caller must still call release(); omitting it leaves an unbounded drain pending. A bounded drain instead resolves with drained: false and the unsettled admission in inFlight. Existing callers that do not use the new abandonment API retain their previous lifecycle.

    No admission call-site changes are required. Instrumented admit and admission-decision reject events gain two optional integer nanosecond fields: decisionDurationNs and queueWaitNs. Code that asserts exact event object shapes should allow these additive fields.

    queueWaitNs is exactly 0 for precheck rejection and otherwise measures the complete awaited concurrency-acquire span. decisionDurationNs excludes that await. Deduplication-follower rejections and observe-mode bypasses are not admission decisions and therefore do not carry admission timing.

    No admission call-site changes are required. Configure protectedConcurrent and/or protectedInFlightTokens only when a class needs a strict local guarantee. The sum of floors must fit inside the corresponding global limit. Floors are not automatically lent while idle; a control plane must adjust them with applyLimits() to implement demand-aware lending.

    stats().admissionClasses gains shared, protected/borrowed usage fields, and cumulative borrowing counters. Rejection capacity details may now use constraint: 'admission_class_protection' and include sharedCapacity. Code that exhaustively asserts these additive object or union shapes must be updated. Omitting both floor fields preserves v3.14 admission behavior.

    No existing call-site changes are required. admissionClasses is opt-in and all new lifecycle fields are optional when the feature is disabled. Code that exhaustively asserts event, stats, limit-snapshot, token, run-context, usage, or rejection-detail shapes should account for the additive class fields. Gateways should pass only trusted, bounded policy-class IDs. Admission class automatically partitions in-flight deduplication, while dedupScope remains required for tenant-level isolation inside a shared class.

    No code changes are required. Update the dependency to v3.11.1 and regenerate your lockfile. The patch keeps the v3.11 API unchanged, replaces the conflicting v3.11.0 package artifact, updates the development dependency lockfile, and corrects the strict capacity-snapshot test expectation.

    No admission call-site changes are required. Successful acquire results, admission tokens, run contexts, usage reports, lifecycle events, and rejection capacity details gain limitRevision. Code that uses exact deep equality on these objects must add the field. Gateways should read the captured revision from the result, token, context, event, or rejection detail instead of calling limits() after the decision.

    Existing admission calls require no changes. stats() gains a limits block, LLMEventType gains "reconfigure", and setBudget() now advances the local revision. Code that exhaustively enumerates event types should add the new case. Control-plane integrations should move from setBudget() to complete applyLimits() snapshots.

    No call-site changes are required. admit and release event payloads gained additional fields, and usage is a new event type. Code that exhaustively enumerates LLMEventType should add the new usage case.

    Update stats access from top-level fields to the bulkhead block:

    const s = bulkhead.stats();

    // v2
    s.inFlight;
    s.pending;

    // v3
    s.bulkhead.inFlight;
    s.bulkhead.pending;

    LLM-layer counters are now available separately:

    const s = bulkhead.stats();
    s.llm.admitted;
    s.llm.rejected;
    s.llm.rejectedByReason?.budget_limit;

    See the changelog for the v2 migration guide.