IMQLock.release() method

Releases a previously acquired lock for a given key.

Signature:

static release<T, E>(key: string, value?: T, err?: E, token?: number): void;

Parameters

Parameter

Type

Description

key

string

key to release the lock for

value

T

(Optional) value to resolve pending calls with

err

E

(Optional) error to reject pending calls with

token

number

(Optional) token from IMQLock.token() proving this release is the holder's own

Returns:

void

Remarks

Pass the token IMQLock.token() gave you when you acquired the lock, and the release is ignored unless the key is still yours. Without it the release is applied unconditionally, which is what this did for every caller: the deadlock timeout frees a key while its holder is still running, so the holder's eventual release landed on whichever call had acquired the key in the meantime — resolving that call's waiters with a result computed for nobody and freeing a lock still in use, which let a third call in behind it.

The token is optional only to keep the signature compatible. A release without one cannot be checked, and stays as unsafe as it was.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.