Reconnect Backoff Helper (channels/backoff.ts)

brigade · src/agents/channels/backoff.ts · typescript · MIT
infra, tag:backoff, tag:reconnect, tag:exponential, tag:jitter, tag:utils

Computes jittered exponential reconnect delays for any channel, centralizing backoff logic so multiple providers can share the same schedule.

// Source: https://github.com/spinabot/brigade | License: MIT | Copyright 2026 Spinabot
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Neutral reconnect-backoff helper — the one place every channel computes a
 * jittered exponential reconnect delay.
 *
 * Before this module each channel carried its own copy of the same five
 * constants + the same delay math: WhatsApp's `backoffDelay` (private to
 * `whatsapp/connection.ts`) and Telegram's `telegramBackoffDelay` (a verbatim
 * copy). Two identical implementations is one too many — a tweak to the curve
 * (say, raising the cap) would have to be made twice and could silently drift.
 * This helper is provider-AGNOSTIC: it takes the schedule as parameters so a
 * caller tuned to a Baileys socket and a caller tuned to a

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key