# awaitInvalidation() function · @imqueue/pg-cache

Source: https://imqueue.org/api/pg-cache/latest/pg-cache.awaitinvalidation/
Published: 2026-08-31
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-cache 5.1.4 — generated reference, not hand-written

Waits for invalidation to be confirmed, but never longer than `timeout`.

**Signature:**

```typescript
export declare function awaitInvalidation(ready: Promise<void>, timeout: number, onTimeout: () => void): Promise<boolean>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| ready | Promise<void> | resolves once invalidation is established; it must never reject, because a rejection here would escape the caller's `start()` |
| timeout | number | milliseconds to wait; a non-positive value falls back to [DEFAULT\_INVALIDATION\_TIMEOUT](https://imqueue.org/api/pg-cache/latest/pg-cache.default_invalidation_timeout/) |
| onTimeout | () => void | called if the wait expires first, to report it |


**Returns:**

Promise<boolean>

true if invalidation was confirmed, false if the wait expired

## Remarks

This is what keeps `start()` honest. The triggers are installed and the channels subscribed from a `connect` event handler, so without waiting for that work `start()` resolves while the cache is already live and nothing can invalidate it. Waiting forever is not an option either — a database that connects but never confirms would hang start-up — so an expired wait reports itself through `onTimeout` and lets the caller continue with caching off.

The timer is always cleared, so a confirmed subscription never leaves a pending timeout behind.

