Skip to content

Conversation

@Arunodoy18
Copy link
Contributor

Prevent unnecessary cache invalidation when the DAG run ID is first loaded. Previously, when a page was initially loaded, the cache would be cleared and queries re-fetched even though the data hadn't changed, resulting in duplicate HTTP requests visible in the network tab.

The fix checks if this is the first time the DAG run ID is being set (previousDagRunIdRef.current === undefined) and if so, sets the ref without invalidating the query cache. Cache invalidation now only occurs when there is an actual new DAG run, which is the intended behavior.

Fixes duplicate requests for /ui/grid/runs, /ui/grid/structure, and other API endpoints on pages like http://localhost:8000/dags/example_branch_labels
Fix duplicate HTTP requests on initial DAG page load

This PR resolves an issue where the UI was making duplicate HTTP requests on initial page load, causing unnecessary network traffic and potential performance degradation.

Problem:
When loading a DAG page (e.g., http://localhost:8000/dags/example_branch_labels), the useRefreshOnNewDagRuns hook was incorrectly invalidating the query cache on the first render. This occurred because:

  • previousDagRunIdRef.current is initialized as undefined
  • When latestDagRunId is fetched for the first time, it differs from undefined
  • The condition previousDagRunIdRef.current !== latestDagRunId triggers cache invalidation
  • All queries are refetched, resulting in duplicate requests for endpoints like /ui/grid/runs, /ui/grid/structure, etc.

Solution:
Added an early return when previousDagRunIdRef.current is undefined (initial load). The ref is set without invalidating queries, ensuring cache invalidation only occurs when a genuinely new DAG run appears:

if (previousDagRunIdRef.current === undefined) {
  previousDagRunIdRef.current = latestDagRunId;
  return;
}

Impact:

  • Eliminates duplicate HTTP requests on initial page load
  • Reduces unnecessary network traffic and improves page load performance
  • Preserves the intended behavior of refreshing data when new DAG runs occur

Testing:

  1. Navigate to any DAG page with existing runs
  2. Open browser DevTools Network tab
  3. Verify each API endpoint is called only once on initial load
  4. Confirm cache invalidation still works correctly when a new DAG run completes

Prevent unnecessary cache invalidation when the DAG run ID is first loaded.
Previously, when a page was initially loaded, the cache would be cleared and
queries re-fetched even though the data hadn't changed, resulting in duplicate
HTTP requests visible in the network tab.

The fix checks if this is the first time the DAG run ID is being set
(previousDagRunIdRef.current === undefined) and if so, sets the ref without
invalidating the query cache. Cache invalidation now only occurs when there
is an actual new DAG run, which is the intended behavior.

Fixes duplicate requests for /ui/grid/runs, /ui/grid/structure, and other
API endpoints on pages like http://localhost:8000/dags/example_branch_labels
@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Dec 23, 2025
@Arunodoy18
Copy link
Contributor Author

THIS ISSUE HAS BEEN RESLOVED, IF ANYONE HAS DOUBT REGARDING THE PR, I would try to follow up regarding the issue .
Thank you.

@potiuk
Copy link
Member

potiuk commented Dec 27, 2025

Closing then

@potiuk potiuk closed this Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants