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
| Parameter | Description |
|---|---|
reason | Whether an external abort or the close deadline stopped the wait. |
cause | The abort reason, or a TimeoutError DOMException for the deadline. |
disposalPromise | The container's shared shutdown promise; it settles when disposal eventually finishes. |
progress | Labels still in progress when the wait stopped. |
waitTimeoutMs? | The deadline that elapsed, for reason: 'timeout'. |
Overrides
ts
Error.constructorProperties
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.