Reduce timeouts

This commit is contained in:
Alex Gleason 2024-07-01 09:18:42 +01:00
parent c3ffe7c7f7
commit 092a20088a
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 6 additions and 6 deletions

View file

@ -73,7 +73,7 @@ function connectStream(socket: WebSocket) {
const pubsub = await Storages.pubsub(); const pubsub = await Storages.pubsub();
try { try {
for (const event of await store.query(filters, { limit: FILTER_LIMIT, timeout: 500 })) { for (const event of await store.query(filters, { limit: FILTER_LIMIT, timeout: 300 })) {
send(['EVENT', subId, event]); send(['EVENT', subId, event]);
} }
} catch (e) { } catch (e) {
@ -128,7 +128,7 @@ function connectStream(socket: WebSocket) {
/** Handle COUNT. Return the number of events matching the filters. */ /** Handle COUNT. Return the number of events matching the filters. */
async function handleCount([_, subId, ...filters]: NostrClientCOUNT): Promise<void> { async function handleCount([_, subId, ...filters]: NostrClientCOUNT): Promise<void> {
const store = await Storages.db(); const store = await Storages.db();
const { count } = await store.count(filters, { timeout: 500 }); const { count } = await store.count(filters, { timeout: 100 });
send(['COUNT', subId, { count, approximate: false }]); send(['COUNT', subId, { count, approximate: false }]);
} }

View file

@ -63,7 +63,7 @@ class EventsDB implements NStore {
await this.deleteEventsAdmin(event); await this.deleteEventsAdmin(event);
try { try {
await this.store.event(event, { ...opts, timeout: opts.timeout ?? 3000 }); await this.store.event(event, { ...opts, timeout: opts.timeout ?? 1000 });
} catch (e) { } catch (e) {
if (e.message === 'Cannot add a deleted event') { if (e.message === 'Cannot add a deleted event') {
throw new RelayError('blocked', 'event deleted by user'); throw new RelayError('blocked', 'event deleted by user');
@ -163,7 +163,7 @@ class EventsDB implements NStore {
this.console.debug('REQ', JSON.stringify(filters)); this.console.debug('REQ', JSON.stringify(filters));
return this.store.query(filters, { ...opts, timeout: opts.timeout ?? 3000 }); return this.store.query(filters, { ...opts, timeout: opts.timeout ?? 1000 });
} }
/** Delete events based on filters from the database. */ /** Delete events based on filters from the database. */
@ -171,7 +171,7 @@ class EventsDB implements NStore {
if (!filters.length) return Promise.resolve(); if (!filters.length) return Promise.resolve();
this.console.debug('DELETE', JSON.stringify(filters)); this.console.debug('DELETE', JSON.stringify(filters));
return this.store.remove(filters, { ...opts, timeout: opts.timeout ?? 5000 }); return this.store.remove(filters, { ...opts, timeout: opts.timeout ?? 3000 });
} }
/** Get number of events that would be returned by filters. */ /** Get number of events that would be returned by filters. */
@ -184,7 +184,7 @@ class EventsDB implements NStore {
this.console.debug('COUNT', JSON.stringify(filters)); this.console.debug('COUNT', JSON.stringify(filters));
return this.store.count(filters, { ...opts, timeout: opts.timeout ?? 1000 }); return this.store.count(filters, { ...opts, timeout: opts.timeout ?? 500 });
} }
/** Return only the tags that should be indexed. */ /** Return only the tags that should be indexed. */