Skip to content

Commit 8ad0c59

Browse files
committed
fix(webapp): drop a skipped query's stale rows and failure
The empty-query short circuit returned before the block that resets rows and the failure flag on a new query signature, so a caller that stopped asking kept the last answer. On the Queues page that meant a readout which failed once on a short range stayed hidden after widening to a range where the readout is skipped entirely and the headline comes from the chart's own successful rows — the number would have been missing for the rest of the session. Reproduced by failing only the p95 readout on a 1-hour range (headline gone as designed) and then widening to 7 days: the headline now returns at 58.3s. Clearing rows as well as the flag, since no query means no data, and leaving another query's rows behind is the same trap the reset below guards against.
1 parent 6309b12 commit 8ad0c59

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

apps/webapp/app/hooks/useMetricResourceQuery.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ function cacheSet(key: string, rows: MetricResourceRow[]) {
5151
* back-navigation to the queues list) shows its last data immediately and revalidates in the
5252
* background rather than flashing a loading skeleton.
5353
*/
54-
/** An empty query means the caller has nothing to ask for, so no request is made. */
54+
/**
55+
* An empty query means the caller has nothing to ask for, so no request is made and any rows or
56+
* failure left by a previous query are dropped — a caller that stops asking must not keep reading
57+
* the last answer, or a stale failure would outlive the query that caused it.
58+
*/
5559
export function useMetricResourceQuery(query: string, opts: MetricResourceQueryOptions) {
5660
const {
5761
organizationId,
@@ -103,6 +107,10 @@ export function useMetricResourceQuery(query: string, opts: MetricResourceQueryO
103107

104108
const load = useCallback(() => {
105109
if (!query) {
110+
abortRef.current?.abort();
111+
loadedKeyRef.current = cacheKey;
112+
setRows(null);
113+
setFailed(false);
106114
setIsLoading(false);
107115
return;
108116
}

0 commit comments

Comments
 (0)