wait a second before failing to send on a not yet connected websocket.

This commit is contained in:
fiatjaf
2023-02-26 16:53:03 -03:00
parent a21329da3f
commit a8938a3a0f

View File

@@ -174,9 +174,12 @@ export function relayInit(url: string): Relay {
async function trySend(params: [string, ...any]) {
let msg = JSON.stringify(params)
if (!connected()) {
await new Promise(resolve => setTimeout(resolve, 1000))
if (!connected()) {
return
}
}
try {
ws.send(msg)
} catch (err) {