Skip to content

fix(issues): Prevent double fetch of group search view endpoint#112324

Merged
scttcper merged 2 commits intomasterfrom
scttcper/fix-view-double-fetch
Apr 7, 2026
Merged

fix(issues): Prevent double fetch of group search view endpoint#112324
scttcper merged 2 commits intomasterfrom
scttcper/fix-view-double-fetch

Conversation

@scttcper
Copy link
Copy Markdown
Member

@scttcper scttcper commented Apr 7, 2026

IssueViewWrapper conditionally renders children behind a loading gate, so child observers mount after the parent's fetch completes. With staleTime: 0 the new observers immediately trigger a second request to /group-search-views/{id}/. Bumping to 30s prevents the redundant request while still refreshing on re-navigation. Mutations already update the cache directly so staleness doesn't matter for user-initiated changes.

IssueViewWrapper conditionally renders children behind a loading gate,
so child observers mount after the parent's fetch completes. With
staleTime: 0 the new observers immediately trigger a second fetch.
Bumping to 30s prevents the redundant request while still refreshing on
re-navigation. Mutations already update the cache directly so staleness
doesn't matter for user-initiated changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 7, 2026
@scttcper scttcper marked this pull request as ready for review April 7, 2026 20:11
@scttcper scttcper requested a review from a team as a code owner April 7, 2026 20:11
@scttcper scttcper requested a review from malwilley April 7, 2026 20:11
return useApiQuery<GroupSearchView>(makeFetchGroupSearchViewKey(parameters), {
staleTime: 0,
staleTime: 30_000,
retry: false,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Setting staleTime: 30_000 in useFetchGroupSearchView can cause view data to be stale for up to 30 seconds in multi-user scenarios.
Severity: MEDIUM

Suggested Fix

Instead of setting a static staleTime, use the initialDataUpdatedAt option when providing initialData. This allows React Query to correctly assess the freshness of the initial data and trigger a background refetch when necessary, resolving the multi-user staleness without causing unnecessary fetches.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/views/issueList/queries/useFetchGroupSearchView.tsx#L26

Potential issue: The introduction of a 30-second `staleTime` in the
`useFetchGroupSearchView` hook creates a data staleness issue in multi-user
environments. When the view is populated using `initialData` from the starred views
cache, this new `staleTime` prevents React Query from immediately refetching the data in
the background. Consequently, if one user modifies a shared view, another user currently
viewing it will not see the updates for up to 30 seconds. This happens because the data
is considered fresh for that duration, even though the underlying source may have
changed.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MULTI USER

@scttcper scttcper merged commit 08ce8e8 into master Apr 7, 2026
67 checks passed
@scttcper scttcper deleted the scttcper/fix-view-double-fetch branch April 7, 2026 20:22
george-sentry pushed a commit that referenced this pull request Apr 9, 2026
)

`IssueViewWrapper` conditionally renders children behind a loading gate,
so child observers mount after the parent's fetch completes. With
`staleTime: 0` the new observers immediately trigger a second request to
`/group-search-views/{id}/`. Bumping to 30s prevents the redundant
request while still refreshing on re-navigation. Mutations already
update the cache directly so staleness doesn't matter for user-initiated
changes.

Co-authored-by: Claude Opus 4.6 <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