Catch client.query calls

This commit is contained in:
Alex Gleason 2024-02-14 15:25:25 -06:00
parent 8d6f8e7d8d
commit 491c3f5125
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 14 additions and 6 deletions

View File

@ -82,9 +82,13 @@ class Optimizer implements NStore {
// Finally, query the client.
this.#debug('Querying client...');
for (const clientEvent of await this.#client.query(filters, opts)) {
results.add(clientEvent);
if (results.size >= limit) return getResults();
try {
for (const clientEvent of await this.#client.query(filters, opts)) {
results.add(clientEvent);
if (results.size >= limit) return getResults();
}
} catch (_e) {
// do nothing
}
/** Get return type from map. */

View File

@ -64,10 +64,14 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: NostrEvent)
if (wantedAuthors.size) filters.push({ kinds: [0], authors: [...wantedAuthors] });
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) {
this.event(event);
for (const event of events) {
this.event(event);
}
} catch (_e) {
// do nothing
}
}