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]) { async function trySend(params: [string, ...any]) {
let msg = JSON.stringify(params) let msg = JSON.stringify(params)
if (!connected()) {
await new Promise(resolve => setTimeout(resolve, 1000))
if (!connected()) { if (!connected()) {
return return
} }
}
try { try {
ws.send(msg) ws.send(msg)
} catch (err) { } catch (err) {