From 9d897e9bf7a6865552182c279a7c440eb853f34b Mon Sep 17 00:00:00 2001 From: ekzyis Date: Thu, 4 Apr 2024 19:28:52 +0200 Subject: [PATCH] Use same onclose listener in sendPayment (#1020) This is the onclose listener from getInfo. This might also be a potential fix for undefined errors that I am getting. With "undefined errors" I mean that the error itself is literally undefined. --- components/webln/nwc.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/webln/nwc.js b/components/webln/nwc.js index 205762da..cfd9b74c 100644 --- a/components/webln/nwc.js +++ b/components/webln/nwc.js @@ -235,8 +235,12 @@ export function NWCProvider ({ children }) { }, onclose (reason) { clearTimeout(timer) - reject(new Error(reason)) - sub?.close() + if (!['closed by caller', 'relay connection closed by us'].includes(reason)) { + // only log if not closed by us (caller) + const msg = 'connection closed: ' + (reason || 'unknown reason') + logger.error(msg) + reject(new Error(msg)) + } } }) })().catch(reject)