Skip to content

DI Bag API / index / DiBagCloseCancelledError

Class: DiBagCloseCancelledError ​

Defined in: errors.ts:212

A close({ waitTimeoutMs, abortSignal }) wait stopped before disposal finished; disposal keeps running. code is DI_BAG_CLOSE_TIMEOUT for the deadline and DI_BAG_CLOSE_ABORTED for the signal.

Example ​

ts
import { DiBag, DiBagCloseCancelledError } from 'di-bag';

const container = DiBag.createBuilder().withServices({ value: () => 1 }).buildContainer();
try {
  await container.close({ waitTimeoutMs: 5_000 });
} catch (error) {
  if (error instanceof DiBagCloseCancelledError) console.error(error.details.disposersStillRunning);
  throw error;
}

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new (reason: "aborted" | "timeout", cause: unknown, disposalPromise: Promise<void>, progress: CloseProgress, waitTimeoutMs?: number): DiBagCloseCancelledError;

Defined in: errors.ts:222

Parameters ​

ParameterDescription
reasonWhether an external abort or the close deadline stopped the wait.
causeThe abort reason, or a TimeoutError DOMException for the deadline.
disposalPromiseThe container's shared shutdown promise; it settles when disposal eventually finishes.
progressLabels still in progress when the wait stopped.
waitTimeoutMs?The deadline that elapsed, for reason: 'timeout'.

Overrides ​

ts
Error.constructor

Properties ​

code ​

ts
declare readonly code: 'DI_BAG_CLOSE_TIMEOUT' | 'DI_BAG_CLOSE_ABORTED';

Defined in: errors.ts:213


details ​

ts
declare readonly details: Readonly<{
    operation: 'close';
    reason: 'aborted' | 'timeout';
    waitTimeoutMs?: number;
} & CloseProgress>;

Defined in: errors.ts:214


disposalPromise ​

ts
readonly disposalPromise: Promise<void>;

Defined in: errors.ts:225

The container's shared shutdown promise; it settles when disposal eventually finishes.


reason ​

ts
readonly reason: 'aborted' | 'timeout';

Defined in: errors.ts:223

Whether an external abort or the close deadline stopped the wait.

Ordinary services. Checked composition. Explicit ownership.