aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ln.ts
Commit message (Collapse)AuthorAgeFilesLines
* ln: time out short-lived RPCs so a hung cl reconnects without restartAdam Soltys2026-06-171-2/+64
| | | | | | | | | | | | | Port of master a664af99. A unix-domain RPC socket has no TCP keepalive, so if cl goes unresponsive while the socket stays open (zombie/half-open) an awaited call hangs forever — nothing throws, the reconnect-on-error path never fires, and only an app restart recovers. Wrap short-lived calls in a 30s Promise.race timeout (matching lib/health.ts); a timeout rejects with ETIMEDOUT, now part of isSocketDied, so the client is dropped and the next call reconnects. Long-polls, in-flight payments (pay/xpay/sendpay/keysend) and bolt12 round-trips are exempt to avoid leaked debits. Co-Authored-By: Claude Opus 4.8 <[email protected]>
* ln/lightning: watchdog recycles zombie receive-listener socketAdam Soltys2026-06-081-0/+1
| | | | | | | | | | | | | | | | | | Port of master bd1ece3 to staging. When cl restarts (e.g. autoheal after a healthcheck timeout), the app's waitanyinvoice long-poll can hang on the now-dead listen socket: listenerActive stays true forever, nothing restarts it, and incoming lightning payments silently stop crediting until a manual app restart. The per-call RPC timeout can't catch this — waitanyinvoice is meant to block. ensureListenerAlive (run every 120s) now also detects a stalled listener — active but blocked in waitanyinvoice for >5min — probes cl via the main socket (getinfo), and only if cl is actually alive treats the listen socket as a zombie: bumps a listenerEpoch, calls lnListen.reset() (new: drops the proxy socket so the next call reconnects), and re-arms. The epoch guard makes the wedged invocation bow out when its waitanyinvoice finally rejects, so we never run two listeners or double-credit. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* handle socket-level errors that bypass Bun's JS error pathAdam Soltys2026-05-171-0/+38
| | | | | | | | | | | | | | | | | Two related defenses around the CLN unix socket connection: - Global net.Socket.prototype.connect patch: when Bun's net.createConnection is called on a non-existent unix socket, the ENOENT it throws bypasses all JS error handlers and crashes the process. existsSync-check the path first; if missing, emit a normal 'error' event so the caller can handle it gracefully. - lightningProxy: existsSync gate before constructing LightningClient, plus a client.on("error") listener that clears the cached client on socket-died errors instead of letting the unhandled event take down the process. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
* conditional lnbAdam Soltys2026-03-161-1/+1
|
* fix typescript issuesAdam Soltys2026-02-281-1/+1
|
* formattingAdam Soltys2026-02-241-2/+2
|
* health checkAdam Soltys2026-02-061-1/+5
|
* more robust lightning clientAdam Soltys2025-12-161-3/+85
|
* xpayAdam Soltys2024-11-271-1/+1
|
* save ecash idAdam Soltys2024-10-241-5/+3
|
* typescriptAdam Soltys2024-08-261-0/+7