From 2c3aff04070180ef22cce914708fdad5163f77c0 Mon Sep 17 00:00:00 2001 From: Gigi Date: Fri, 17 Oct 2025 13:09:42 +0200 Subject: [PATCH] perf(bunker): make NIP-46 publish non-blocking at app wiring level; resolve immediately and let responses drive timing/results --- src/App.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index e8a3c64a..568b6b36 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -195,9 +195,17 @@ function App() { // Create relay pool and set it up BEFORE loading accounts // NostrConnectAccount.fromJSON needs this to restore the signer const pool = new RelayPool() - // Wire the signer to use this pool's publish/subscription methods (per applesauce examples) + // Wire the signer to use this pool; make publish non-blocking so callers don't + // wait for every relay send to finish. Responses still resolve the pending request. NostrConnectSigner.subscriptionMethod = pool.subscription.bind(pool) - NostrConnectSigner.publishMethod = pool.publish.bind(pool) + NostrConnectSigner.publishMethod = (relays: string[], event: unknown) => { + const result: any = pool.publish(relays, event as any) + if (result && typeof (result as any).subscribe === 'function') { + try { (result as any).subscribe({ complete: () => {}, error: () => {} }) } catch {} + } + // Return an already-resolved promise so upstream await finishes immediately + return Promise.resolve() + } console.log('[bunker] ✅ Wired NostrConnectSigner to RelayPool publish/subscription (before account load)') // Create a relay group for better event deduplication and management