From 3bebe7748c29cc61faf3fc4c64e010678f8d7ea5 Mon Sep 17 00:00:00 2001 From: Chris Harris Date: Fri, 6 Mar 2026 08:11:27 -0600 Subject: [PATCH] fix(sync): skip unparseable queries during poll Promise.all in QueryCache.sync crashes the entire poll when a single query from pg_stat_statements fails to parse (e.g. utility commands with $1 placeholders). Use Promise.allSettled to skip failures and return successfully parsed queries. Co-Authored-By: Claude Opus 4.6 --- src/sync/seen-cache.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sync/seen-cache.ts b/src/sync/seen-cache.ts index 8d7ea4b..a6b4b2d 100644 --- a/src/sync/seen-cache.ts +++ b/src/sync/seen-cache.ts @@ -49,7 +49,7 @@ export class QueryCache { async sync(rawQueries: RawRecentQuery[]): Promise { // TODO: bound the concurrency - return await Promise.all(rawQueries.map(async (rawQuery) => { + const results = await Promise.allSettled(rawQueries.map(async (rawQuery) => { const key = await this.store(rawQuery); try { return await RecentQuery.analyze(rawQuery, key, this.getFirstSeen(key)); @@ -59,6 +59,9 @@ export class QueryCache { throw error; } })); + return results + .filter((r): r is PromiseFulfilledResult => r.status === "fulfilled") + .map((r) => r.value); } reset(): void {