DEVPROD-18977: Remove repo redirect and introduce useQueryCompleted#1337
Open
minnakt wants to merge 2 commits intoevergreen-ci:mainfrom
Open
DEVPROD-18977: Remove repo redirect and introduce useQueryCompleted#1337minnakt wants to merge 2 commits intoevergreen-ci:mainfrom
useQueryCompleted#1337minnakt wants to merge 2 commits intoevergreen-ci:mainfrom
Conversation
useCompletedQueryuseQueryCompleted
Comment on lines
+46
to
50
| useQueryCompleted(loading, () => { | ||
| if (columnData && !columnData.taskNamesForBuildVariant) { | ||
| reportError(new Error("No task names found for build variant")).warning(); | ||
| dispatchToast.error(`No tasks found for build variant: ${variantName}}`); | ||
| } |
There was a problem hiding this comment.
Bug: The useQueryCompleted hook doesn't reset its state on variant change, preventing error toasts from showing when navigating to a variant with cached but empty data.
Severity: MEDIUM
Suggested Fix
The useQueryCompleted hook should be modified to accept a dependency array. This array should include variables like projectIdentifier and variantName to ensure the hook's internal state is reset whenever the query's key variables change, not just when the loading state transitions.
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: apps/spruce/src/pages/variantHistory/ColumnHeaders.tsx#L46-L50
Potential issue: The `useQueryCompleted` hook in `ColumnHeaders.tsx` fails to show an
error toast when a user navigates from one variant to another. If Apollo Client serves
the data for the new variant from its cache without changing the `loading` state, the
hook's internal completion flag is not reset. This prevents the error callback from
executing, even if the cached data indicates an error (e.g., is empty). This behavior is
a regression from the previous implementation, which explicitly reset the error state
when the variant changed.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DEVPROD-18977
Description
/projectroute in the past month (Honeycomb link)useProjectRedirecthookuseCompletedQueryhook to handleonCompleteduse cases that we lost after Apollo deprecationTesting