Skip to content

Commit c699187

Browse files
committed
fix(webapp): keep a plan-limit failure from taking the Queues page down
The query-period lookup runs before the block that renders the Queues page without metrics when ClickHouse is unavailable, so a failure reading the limit would have cost the whole page rather than the time filter. It now falls back to the retention cap, which is the widest window the data can cover anyway.
1 parent c40f779 commit c699187

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getCachedLimit } from "~/services/platform.v3.server";
2+
import { logger } from "~/services/logger.server";
23
import { QUEUE_METRICS_RETENTION_DAYS } from "./queueMetricsPeriod";
34

45
/**
@@ -7,14 +8,24 @@ import { QUEUE_METRICS_RETENTION_DAYS } from "./queueMetricsPeriod";
78
* and go straight to ClickHouse stay in step with the ones that don't.
89
*
910
* Read through the limit cache: the queues page revalidates on an interval, so this runs far more
10-
* often than a one-off page load.
11+
* often than a one-off page load. Never throws, so a cache or platform outage costs the caller its
12+
* time filter rather than the whole page: the retention cap is the widest window the data can cover
13+
* anyway, and the queries stay tenant-scoped either way.
1114
*/
1215
export async function queueMetricsMaxPeriodDays(organizationId: string): Promise<number> {
13-
const cached = await getCachedLimit(
14-
organizationId,
15-
"queryPeriodDays",
16-
QUEUE_METRICS_RETENTION_DAYS
17-
);
18-
const planPeriodDays = cached.val ?? QUEUE_METRICS_RETENTION_DAYS;
19-
return Math.min(planPeriodDays, QUEUE_METRICS_RETENTION_DAYS);
16+
try {
17+
const cached = await getCachedLimit(
18+
organizationId,
19+
"queryPeriodDays",
20+
QUEUE_METRICS_RETENTION_DAYS
21+
);
22+
const planPeriodDays = cached.val ?? QUEUE_METRICS_RETENTION_DAYS;
23+
return Math.min(planPeriodDays, QUEUE_METRICS_RETENTION_DAYS);
24+
} catch (error) {
25+
logger.warn("Queue metrics query period limit unavailable, falling back to retention", {
26+
organizationId,
27+
error,
28+
});
29+
return QUEUE_METRICS_RETENTION_DAYS;
30+
}
2031
}

0 commit comments

Comments
 (0)