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.
This commit is contained in:
ekzyis 2024-04-04 19:28:52 +02:00 committed by GitHub
parent 6e75b9d274
commit 9d897e9bf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -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)