From c57a665655e3ec1c891759ee5e2a0f8fc842660c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Mon, 20 Apr 2026 12:14:45 +0400 Subject: [PATCH] Add applesauce debug logs, fix aggressive connect timeout --- app/services/nostr-auth.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/app/services/nostr-auth.js b/app/services/nostr-auth.js index 5b4e7e5..1d50f1a 100644 --- a/app/services/nostr-auth.js +++ b/app/services/nostr-auth.js @@ -26,6 +26,12 @@ export default class NostrAuthService extends Service { constructor() { super(...arguments); + + // Enable debug logging for applesauce packages + if (typeof localStorage !== 'undefined') { + localStorage.debug = 'applesauce:*'; + } + const saved = localStorage.getItem(STORAGE_KEY); const type = localStorage.getItem(STORAGE_KEY_TYPE); if (saved) { @@ -132,6 +138,9 @@ export default class NostrAuthService extends Service { const relay = 'wss://relay.nsec.app'; localStorage.setItem(STORAGE_KEY_CONNECT_RELAY, relay); + // Override aggressive 10s EOSE timeout to allow time for QR scanning + this.nostrRelay.pool.relay(relay).eoseTimeout = 180000; // 3 minutes + this._signerInstance = new NostrConnectSigner({ pool: this.nostrRelay.pool, relays: [relay], @@ -153,20 +162,30 @@ export default class NostrAuthService extends Service { this.connectUri = this._signerInstance.getNostrConnectURI({ name: 'Marco', url: window.location.origin, - description: 'A privacy-respecting maps application.', + description: 'An unhosted maps application.', icons: [], }); // Trigger the deep link intent immediately for the user if on mobile if (this.isMobile) { + console.debug('Mobile detected, triggering deep link intent.'); window.location.href = this.connectUri; } // Start listening to the relay + console.debug('Opening signer connection to relay...'); await this._signerInstance.open(); + console.debug('Signer connection opened successfully.'); // Wait for the remote signer to reply with their pubkey - await this._signerInstance.waitForSigner(); + console.debug('Waiting for remote signer to ack via relay...'); + try { + await this._signerInstance.waitForSigner(); + console.debug('Remote signer ack received!'); + } catch (waitErr) { + console.error('Error while waiting for remote signer ack:', waitErr); + throw waitErr; + } // Once connected, get the actual user pubkey this.pubkey = await this._signerInstance.getPublicKey(); @@ -204,6 +223,9 @@ export default class NostrAuthService extends Service { const localSigner = PrivateKeySigner.fromKey(localKeyHex); + // Override aggressive 10s EOSE timeout to allow time for QR scanning + this.nostrRelay.pool.relay(relay).eoseTimeout = 180000; // 3 minutes + this._signerInstance = new NostrConnectSigner({ pool: this.nostrRelay.pool, relays: [relay],