Skip to content

Commit 99f4f62

Browse files
committed
fix(ndk): add connect timeout and enable reset during load
1 parent 8680574 commit 99f4f62

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/contexts/NDKContext.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,18 @@ export function NDKProvider({ children, relays }: NDKProviderProps) {
5656
useEffect(() => {
5757
const updateRelays = async () => {
5858
try {
59-
await ndkInstance.connect(2000); // 2s timeout for initial connection attempt
59+
console.log('🔌 NDK Connecting to relays:', relays);
60+
await ndkInstance.connect(2500); // 2.5s timeout
61+
console.log('✅ NDK Connected. Active pool size:', ndkInstance.pool.connectedRelays().length);
62+
63+
// Log individual relay statuses
64+
ndkInstance.pool.relays.forEach(r => {
65+
console.debug(`Relay ${r.url}: Status ${r.status}, Connection: ${r.connectivityStatus}`);
66+
});
67+
6068
} catch (err) {
61-
console.error('Failed to connect to NDK relays:', err);
69+
console.warn('⚠️ NDK Connection timeout or partial failure:', err);
70+
// We still proceed, as some relays might be connected or we can work offline/later
6271
} finally {
6372
setIsLoading(false);
6473
}

src/pages/Settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function ResetKeyButton() {
139139
<Button
140140
variant="destructive"
141141
onClick={handleReset}
142-
disabled={isLoading || initializeKey.isPending}
142+
disabled={initializeKey.isPending} // Allow reset even if query is "loading" (stuck)
143143
>
144144
{initializeKey.isPending ? 'Resetting...' : 'Reset Inventory Key'}
145145
</Button>

0 commit comments

Comments
 (0)