aboutsummaryrefslogtreecommitdiffstats
path: root/patches/@asoltys+clightning-client+0.1.10.patch
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-16 00:23:28 -0700
committerAdam Soltys <[email protected]>2026-08-16 00:23:28 -0700
commit984d2c3efeca25c37522c6fb17a9863717b44bc2 (patch)
tree8a710128db8e0e5aa63510e2fb51021ae0d222e7 /patches/@asoltys+clightning-client+0.1.10.patch
parent7c6805decc508b009673e1a5651b2a86ebdef717 (diff)
downloadcoinos-server-984d2c3efeca25c37522c6fb17a9863717b44bc2.tar.gz
coinos-server-984d2c3efeca25c37522c6fb17a9863717b44bc2.zip
deps: patch @asoltys/clightning-client to fix cl reconnect
Register patches/@asoltys+clightning-client+0.1.10.patch via patchedDependencies so bun install re-applies it. The library's reconnect() reused an already-dead socket and never recovered after a cl restart (looping connect ENOENT, leaking a socket+timer); the patch rebuilds a fresh socket + readline each reconnection and clears its retry guard before reconnecting. Companion to the app-side dropClient()/listener-recovery fixes. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Diffstat (limited to 'patches/@asoltys+clightning-client+0.1.10.patch')
-rw-r--r--patches/@asoltys+clightning-client+0.1.10.patch54
1 files changed, 54 insertions, 0 deletions
diff --git a/patches/@asoltys+clightning-client+0.1.10.patch b/patches/@asoltys+clightning-client+0.1.10.patch
new file mode 100644
index 00000000..f2d0d3d4
--- /dev/null
+++ b/patches/@asoltys+clightning-client+0.1.10.patch
@@ -0,0 +1,54 @@
+diff --git a/index.js b/index.js
+index 968489c..4d96c34 100644
+--- a/index.js
++++ b/index.js
+@@ -42,7 +42,31 @@ class LightningClient extends EventEmitter {
+ this.reconnectTimeout = null;
+ this.reqcount = 0;
+
+- this.client = net.createConnection(rpcPath);
++ this._setup();
++ }
++
++ _setup() {
++ // Build a FRESH socket + readline for every (re)connection. The original
++ // code reused this.client and only called this.client.connect() on
++ // reconnect — but a socket that has already emitted 'error'/'close' is
++ // destroyed, so reconnecting it is a no-op/throw. That left the client
++ // wedged looping `connect ENOENT …/lightning-rpc` forever after a cl
++ // restart (spamming logs, leaking a socket+timer, never recovering).
++ // Renewing clientConnectionPromise here also makes call() block until the
++ // (re)connection is live instead of writing into a dead socket.
++ if (this.client) {
++ try {
++ this.client.removeAllListeners();
++ this.client.destroy();
++ } catch (e) {}
++ }
++ if (this.rl) {
++ try {
++ this.rl.close();
++ } catch (e) {}
++ }
++
++ this.client = net.createConnection(this.rpcPath);
+ this.rl = readline.createInterface({ input: this.client });
+
+ this.clientConnectionPromise = new Promise((resolve) => {
+@@ -87,8 +111,15 @@ class LightningClient extends EventEmitter {
+ }
+
+ this.reconnectTimeout = setTimeout(() => {
+- this.client.connect(this.rpcPath);
++ // Clear the guard BEFORE (re)connecting so a throw can't leave it set
++ // and permanently block every future reconnect() (the original bug).
+ this.reconnectTimeout = null;
++ try {
++ this._setup();
++ } catch (e) {
++ this.increaseWaitTime();
++ this.reconnect();
++ }
+ }, this.reconnectWait * 1000);
+ }
+