mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Catch client.query calls
This commit is contained in:
parent
8d6f8e7d8d
commit
491c3f5125
2 changed files with 14 additions and 6 deletions
|
|
@ -82,9 +82,13 @@ class Optimizer implements NStore {
|
||||||
|
|
||||||
// Finally, query the client.
|
// Finally, query the client.
|
||||||
this.#debug('Querying client...');
|
this.#debug('Querying client...');
|
||||||
for (const clientEvent of await this.#client.query(filters, opts)) {
|
try {
|
||||||
results.add(clientEvent);
|
for (const clientEvent of await this.#client.query(filters, opts)) {
|
||||||
if (results.size >= limit) return getResults();
|
results.add(clientEvent);
|
||||||
|
if (results.size >= limit) return getResults();
|
||||||
|
}
|
||||||
|
} catch (_e) {
|
||||||
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get return type from map. */
|
/** Get return type from map. */
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,14 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: NostrEvent)
|
||||||
if (wantedAuthors.size) filters.push({ kinds: [0], authors: [...wantedAuthors] });
|
if (wantedAuthors.size) filters.push({ kinds: [0], authors: [...wantedAuthors] });
|
||||||
|
|
||||||
if (filters.length) {
|
if (filters.length) {
|
||||||
const events = await client.query(filters, { signal: AbortSignal.timeout(timeout) });
|
try {
|
||||||
|
const events = await client.query(filters, { signal: AbortSignal.timeout(timeout) });
|
||||||
|
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
this.event(event);
|
this.event(event);
|
||||||
|
}
|
||||||
|
} catch (_e) {
|
||||||
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue