Skip to content

fix(replays): correct query invalidation on refresh#115629

Merged
JoshuaKGoldberg merged 4 commits into
masterfrom
replay-live-correct-query-invalidation
May 21, 2026
Merged

fix(replays): correct query invalidation on refresh#115629
JoshuaKGoldberg merged 4 commits into
masterfrom
replay-live-correct-query-invalidation

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

I'm somewhat low confidence I've understood the current/new query key plumbing correct. But I think this corrects the doRefresh callback to properly clear the replay & replay-segments data?

Fixes REPLAY-910.

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 15, 2026

REPLAY-910

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 15, 2026
@JoshuaKGoldberg JoshuaKGoldberg requested a review from TkDodo May 15, 2026 14:32
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 15, 2026

📊 Type Coverage Diff

Metric Before After Delta
Coverage 93.60% 93.60% ±0%
Typed 135,662 135,666 🟢 +4
Untyped 9,269 9,270 🔴 +1
🔍 1 new type safety issue introduced

Non-null assertions (!) (1 new)

File Line Detail
static/app/components/replays/replayLiveIndicator.tsx 132 useReplayProjectSlug({replayRecord: replay})!

This is informational only and does not block the PR.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review May 15, 2026 14:33
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner May 15, 2026 14:33

const queryClient = useQueryClient();
const projectSlug = useReplayProjectSlug({replayRecord: replay});
const projectSlug = useReplayProjectSlug({replayRecord: replay})!;
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.

I don't like adding this !. But projectSlug is only used in places where it's defined...

Comment thread static/app/components/replays/replayLiveIndicator.tsx Outdated
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

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

I guess a test might be a good thing to add?

Comment thread static/app/components/replays/replayLiveIndicator.tsx Outdated
Comment thread static/app/components/replays/replayLiveIndicator.tsx Outdated
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

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

I thought one part of the problem was that we wouldn’t want to invalidate queries that are polling ? At least you had that in the previous solution. So wouldn’t we need to migrate this one to replayRecordApiOptions too:

const queryKey: ApiQueryKey = [
getApiUrl('/organizations/$organizationIdOrSlug/replays/$replayId/', {
path: {organizationIdOrSlug: orgSlug, replayId},
}),
{
// we use { isPolling: true } to avoid colliding with the queryKey used by useReplayData
query: {isPolling: true},
},
];

and then make isPolling a required param to the function so that we only invalidate the ones were isPolling is false ?

Comment on lines +164 to +165
projectIdOrSlug: projectSlug!,
replayId: replayId!,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we could accept string | undefined here as input for those ids and then use skipToken internally to avoid the type assertion

Copy link
Copy Markdown
Member Author

@JoshuaKGoldberg JoshuaKGoldberg May 21, 2026

Choose a reason for hiding this comment

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

(talked 1:1) Existing code - I would love to refactor this, but since I'm just doing this as a spot fix for a virtual team, that'll have to be a followup. 😞

Comment thread static/app/components/replays/replayLiveIndicator.tsx
@JoshuaKGoldberg JoshuaKGoldberg merged commit 067fb07 into master May 21, 2026
71 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the replay-live-correct-query-invalidation branch May 21, 2026 14:32
JonasBa pushed a commit that referenced this pull request May 21, 2026
I'm somewhat low confidence I've understood the current/new query key
plumbing correct. But I think this corrects the `doRefresh` callback to
properly clear the replay & replay-segments data?

Fixes REPLAY-910.
natemoo-re pushed a commit that referenced this pull request May 21, 2026
I'm somewhat low confidence I've understood the current/new query key
plumbing correct. But I think this corrects the `doRefresh` callback to
properly clear the replay & replay-segments data?

Fixes REPLAY-910.
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