Skip to content

Commit 3ccc5d2

Browse files
authored
Fix run metadata loading when deep linking executions (#1402)
## Fix run metadata loading when deep linking executions - give `useFetchPipelineRunMetadata` its own query key so metadata no longer shares cache entries with execution-state queries, preventing the two requests from clobbering each other - have `ExecutionDataProvider` derive the correct run id before requesting metadata so the query refires after navigating straight to an execution or toggling between subgraphs This stops the race that was dropping run details and the cancel button when opening runs by execution id or jumping back to the root graph. ## Type of Change - [x] Improvement - [x] Cleanup/Refactor ## Checklist - [x] I have tested this does not break current pipelines / runs functionality - [x] I have tested the changes on staging ## Test Instructions 1. Navigate to pipeline run details pages 2. Verify that pipeline metadata is correctly loaded 3. Check that nested executions properly fetch metadata only when needed
1 parent 99c3437 commit 3ccc5d2

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/components/PipelineRun/RunDetails.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ describe("<RunDetails/>", () => {
136136
error: null,
137137
});
138138

139-
queryClient.setQueryData(["pipeline-run", "123"], mockPipelineRun);
139+
queryClient.setQueryData(["pipeline-run-metadata", "123"], mockPipelineRun);
140140

141141
vi.mocked(executionService.countTaskStatuses).mockReturnValue({
142142
total: 2,
@@ -278,7 +278,7 @@ describe("<RunDetails/>", () => {
278278
};
279279

280280
queryClient.setQueryData(
281-
["pipeline-run", "123"],
281+
["pipeline-run-metadata", "123"],
282282
pipelineRunWithDifferentCreator,
283283
);
284284

src/providers/ExecutionDataProvider.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,20 @@ export function ExecutionDataProvider({
152152
error: pipelineRunError,
153153
} = usePipelineRunData(pipelineRunId);
154154

155+
const { details: rootDetails, state: rootState } = executionData ?? {};
156+
const runId = rootDetails?.pipeline_run_id;
157+
158+
const metadataQueryId =
159+
runId ??
160+
(rootExecutionId && pipelineRunId === rootExecutionId
161+
? undefined
162+
: pipelineRunId);
163+
155164
const {
156165
data: metadata,
157166
isLoading: isLoadingPipelineMetadata,
158167
error: pipelineMetadataError,
159-
} = useFetchPipelineRunMetadata(pipelineRunId);
160-
161-
const { details: rootDetails, state: rootState } = executionData ?? {};
162-
const runId = rootDetails?.pipeline_run_id;
168+
} = useFetchPipelineRunMetadata(metadataQueryId);
163169

164170
const {
165171
path: urlDerivedPath,
@@ -239,8 +245,8 @@ export function ExecutionDataProvider({
239245
// before rendering to avoid flashing the root level
240246
const isLoading = isAtRoot
241247
? isLoadingPipelineRunData ||
242-
(!!subgraphExecutionId && isLoadingBreadcrumbs) ||
243-
isLoadingPipelineMetadata
248+
(!!subgraphExecutionId && isLoadingBreadcrumbs) ||
249+
isLoadingPipelineMetadata
244250
: isNestedLoading || isLoadingBreadcrumbs;
245251
const error = isAtRoot
246252
? pipelineRunError || pipelineMetadataError

src/services/executionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const useFetchPipelineRunMetadata = (runId: string | undefined) => {
4343
const { backendUrl } = useBackend();
4444

4545
return useQuery<PipelineRunResponse>({
46-
queryKey: ["pipeline-run", runId],
46+
queryKey: ["pipeline-run-metadata", runId],
4747
queryFn: () => fetchPipelineRun(runId!, backendUrl),
4848
enabled: !!runId,
4949
refetchOnWindowFocus: false,

0 commit comments

Comments
 (0)