diff --git a/src/daemon/admin/index.ts b/src/daemon/admin/index.ts index a54ad60..36764bb 100644 --- a/src/daemon/admin/index.ts +++ b/src/daemon/admin/index.ts @@ -127,8 +127,15 @@ class AdminInterface { const sk = secretKeyBytes(this.adminNsec); const pool = new RelayPool(['wss://blastr.f7z.xyz', 'wss://nostr.mutinywallet.com'], {}); pool.start(); - // Give the connections a moment to come up before publishing. - await new Promise((r) => setTimeout(r, 2500)); + // Wait until at least one relay is actually connected (capped), rather + // than a fixed sleep — these external public relays can be slow to come + // up, and a too-short fixed wait made the DM publish fail on boot. Still + // best-effort: if none connect in time we fall through and dmUser logs + // the publish failure without affecting the daemon. (#48) + const deadline = Date.now() + 8000; + while (pool.connectedCount() === 0 && Date.now() < deadline) { + await new Promise((r) => setTimeout(r, 100)); + } for (const npub of this.npubs || []) { await dmUser(sk, npub, `nsecBunker has started; use ${connectionString} to connect to it and unlock your key(s)`, pool);