Skip to content

Commit 84c5b59

Browse files
committed
fix: fail-fast on Fragment DO errors instead of silent partial results
Previously, if some Fragment DOs failed during fan-out, we silently returned partial data (missing rows). Now any failure throws immediately with a clear error message showing how many fragments failed and why.
1 parent 71c4dc3 commit 84c5b59

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/query-do.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,16 +1837,19 @@ export class QueryDO extends DurableObject<Env> {
18371837
}));
18381838

18391839
const fulfilled: QueryResult[] = [];
1840+
const failures: string[] = [];
18401841
for (const s of settled) {
18411842
if (s.status === "fulfilled") {
18421843
fulfilled.push(s.value);
18431844
} else {
1844-
this.log("warn", "fragment_do_failed", { reason: String(s.reason) });
1845+
const reason = String(s.reason);
1846+
failures.push(reason);
1847+
this.log("error", "fragment_do_failed", { reason });
18451848
}
18461849
}
18471850

1848-
if (fulfilled.length === 0) {
1849-
throw new Error("All Fragment DOs failed");
1851+
if (failures.length > 0) {
1852+
throw new Error(`${failures.length}/${settled.length} Fragment DOs failed: ${failures[0]}`);
18501853
}
18511854

18521855
const merged = mergeQueryResults(fulfilled, query);

0 commit comments

Comments
 (0)