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
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
1 changed files with 4 additions and 1 deletions

View File

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