# PgIpLock.onAcquire() method · @imqueue/pg-pubsub

Source: https://imqueue.org/api/pg-pubsub/latest/pg-pubsub.pgiplock.onacquire/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-pubsub 3.0.5 — generated reference, not hand-written

This would provide a late acquire handler which will be called once the lock is taken over by the retry timer, with the channel name bypassed to a given handler.

Acquiring the lock is only ever half of the caller's job - the other half (issuing `LISTEN`, in the PgPubSub case) happens right after acquire() returns true. When the first attempt loses to another process, that caller is long gone by the time the timer wins the lock, so without this handler the second half never runs and the lock is held by a process that does nothing with it - forever, since a held lock keeps every other process away too.

**Signature:**

```typescript
onAcquire(handler: (channel: string) => void): void;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| handler | (channel: string) => void | called with the channel name when this lock changes hands |


**Returns:**

void

