Skip to content

fix(preprod): Gate comparison download query on SUCCESS state#109923

Merged
NicoHinderling merged 1 commit intomasterfrom
NicoHinderling/fix/size-compare-race-condition
Mar 5, 2026
Merged

fix(preprod): Gate comparison download query on SUCCESS state#109923
NicoHinderling merged 1 commit intomasterfrom
NicoHinderling/fix/size-compare-race-condition

Conversation

@NicoHinderling
Copy link
Contributor

@NicoHinderling NicoHinderling commented Mar 5, 2026

The comparison data download query (comparisonDataQuery) fires as soon as metric IDs are available from the status polling query, regardless of whether the async Celery comparison task has actually completed. When the comparison state is still PENDING or PROCESSING, the download endpoint returns 404 because the comparison file hasn't been created yet. React Query exhausts its retries and caches the error. Later, when the status poll detects the transition to SUCCESS, the download query doesn't re-fire because it already has a cached (error) response — resulting in "Comparison not found" being shown to the user.

Adds mainArtifactComparison?.state === SizeAnalysisComparisonState.SUCCESS to the enabled condition of the download query. This ensures the query only fires after the comparison is confirmed complete, at which point the file is guaranteed to exist. The existing 10-second refetchInterval on the status query handles detecting the state transition.

Reported by customer — the issue reproduced ~50% of the time on initial load but always resolved on page reload (because by then the comparison had completed and the SUCCESS state was returned immediately).

The comparison data download query fires as soon as metric IDs are
available, regardless of whether the async Celery comparison task has
completed. When the comparison is still PENDING/PROCESSING, the
download endpoint returns 404. React Query caches this error, and
when the status poll detects SUCCESS, the stale error is shown instead
of fetching the now-available data.

Add a state check to the enabled condition so the download query only
fires after the comparison is confirmed complete.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 5, 2026
@NicoHinderling NicoHinderling marked this pull request as ready for review March 5, 2026 00:03
@NicoHinderling NicoHinderling requested a review from a team as a code owner March 5, 2026 00:03
@NicoHinderling NicoHinderling merged commit 3894ee5 into master Mar 5, 2026
63 checks passed
@NicoHinderling NicoHinderling deleted the NicoHinderling/fix/size-compare-race-condition branch March 5, 2026 00:56
JonasBa pushed a commit that referenced this pull request Mar 5, 2026
The comparison data download query (`comparisonDataQuery`) fires as soon
as metric IDs are available from the status polling query, regardless of
whether the async Celery comparison task has actually completed. When
the comparison state is still PENDING or PROCESSING, the download
endpoint returns 404 because the comparison file hasn't been created
yet. React Query exhausts its retries and caches the error. Later, when
the status poll detects the transition to SUCCESS, the download query
doesn't re-fire because it already has a cached (error) response —
resulting in "Comparison not found" being shown to the user.

Adds `mainArtifactComparison?.state ===
SizeAnalysisComparisonState.SUCCESS` to the `enabled` condition of the
download query. This ensures the query only fires after the comparison
is confirmed complete, at which point the file is guaranteed to exist.
The existing 10-second `refetchInterval` on the status query handles
detecting the state transition.

Reported by customer — the issue reproduced ~50% of the time on initial
load but always resolved on page reload (because by then the comparison
had completed and the SUCCESS state was returned immediately).

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants