Fix leaking relay connections

This commit is contained in:
ekzyis 2024-07-15 13:55:34 +02:00
parent 6ac675429c
commit ee1574cf45
1 changed files with 6 additions and 4 deletions

View File

@ -67,8 +67,9 @@ export async function validate ({ nwcUrl }, { logger }) {
}) })
}) })
} finally { } finally {
// For some reason, websocket is already in CLOSING or CLOSED state. // For some reason, this throws 'WebSocket is already in CLOSING or CLOSED state'
// relay?.close() // even though relay connection is still open here
relay?.close()?.catch()
if (relay) logger.info(`closed connection to ${relayUrl}`) if (relay) logger.info(`closed connection to ${relayUrl}`)
} }
} }
@ -126,8 +127,9 @@ export async function sendPayment (bolt11, { nwcUrl }, { logger }) {
}) })
return ret return ret
} finally { } finally {
// For some reason, websocket is already in CLOSING or CLOSED state. // For some reason, this throws 'WebSocket is already in CLOSING or CLOSED state'
// relay?.close() // even though relay connection is still open here
relay?.close()?.catch()
if (relay) logger.info(`closed connection to ${relayUrl}`) if (relay) logger.info(`closed connection to ${relayUrl}`)
} }
} }