Fix worker unresponsiveness: fire-and-forget cache writes + remove per-event console.log
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"VERSION": "v0.7.92",
|
||||
"VERSION_NUMBER": "0.7.92",
|
||||
"BUILD_DATE": "2026-07-01T22:55:25.679Z"
|
||||
"VERSION": "v0.7.93",
|
||||
"VERSION_NUMBER": "0.7.93",
|
||||
"BUILD_DATE": "2026-07-03T10:29:34.780Z"
|
||||
}
|
||||
|
||||
@@ -1049,9 +1049,8 @@ function pruneSeenEventIds(seenEventIds) {
|
||||
function wireSubscriptionHandlers(subId, state, filtersForCache) {
|
||||
if (!state?.sub) return;
|
||||
|
||||
state.sub.on('event', async (event) => {
|
||||
state.sub.on('event', (event) => {
|
||||
if (state.seenEventIds.has(event.id)) {
|
||||
console.log('[Worker] Dedup dropped event for sub:', subId, 'id:', event.id);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1063,14 +1062,7 @@ function wireSubscriptionHandlers(subId, state, filtersForCache) {
|
||||
state.lastEventCreatedAt = Math.max(Number(state.lastEventCreatedAt || 0), createdAt);
|
||||
}
|
||||
|
||||
console.log('[Worker] Event received for sub:', subId, 'kind:', event.kind, 'id:', event.id);
|
||||
|
||||
if (isWorkerEventMuted(event)) {
|
||||
console.log('[Worker][mute] Filtered muted event for sub:', subId, {
|
||||
id: event?.id || null,
|
||||
kind: event?.kind || null,
|
||||
pubkey: event?.pubkey || null,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1079,14 +1071,14 @@ function wireSubscriptionHandlers(subId, state, filtersForCache) {
|
||||
trackRelayRead(event.relay.url);
|
||||
}
|
||||
|
||||
// Cache the event to IndexedDB
|
||||
// Cache the event to IndexedDB — fire-and-forget (NOT awaited).
|
||||
// Awaiting serializes all incoming events through IndexedDB I/O,
|
||||
// which blocks the worker's event loop and starves port.onmessage
|
||||
// handlers (getRelayData, getRelayStats, etc.), causing 15s timeouts
|
||||
// and relay indicators disappearing over extended sessions.
|
||||
if (ndk.cacheAdapter && typeof ndk.cacheAdapter.setEvent === 'function') {
|
||||
try {
|
||||
await ndk.cacheAdapter.setEvent(event, filtersForCache, event.relay);
|
||||
console.log('[Worker] Cached event:', event.id, 'from relay:', event.relay?.url);
|
||||
} catch (error) {
|
||||
console.error('[Worker] Failed to cache event:', error);
|
||||
}
|
||||
void ndk.cacheAdapter.setEvent(event, filtersForCache, event.relay)
|
||||
.catch(error => console.error('[Worker] Failed to cache event:', error));
|
||||
}
|
||||
|
||||
broadcast({
|
||||
|
||||
Reference in New Issue
Block a user