Skip to content

Commit

Permalink
fix(dashboards): Prevent fetch thrashing in Project Details pages (#8…
Browse files Browse the repository at this point in the history
…1988)

Under some conditions, project score cards keep re-fetching data. A data
fetch finishes, the component re-renders, and this re-runs the `useApi`
hooks since the second timestamp has changed.

This is easy to side-step by setting a high `staleTime`. In this case,
we do not want _any_ passive refetches, so an infinite stale time makes
sure that's the case.
  • Loading branch information
gggritso authored Dec 11, 2024
1 parent d4dbf62 commit 9e37e68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const useApdex = (props: Props) => {
},
},
],
{staleTime: 0, enabled: isEnabled}
{staleTime: Infinity, enabled: isEnabled}
);

const isPreviousPeriodEnabled = shouldFetchPreviousPeriod({
Expand All @@ -82,7 +82,7 @@ const useApdex = (props: Props) => {
},
],
{
staleTime: 0,
staleTime: Infinity,
enabled: isEnabled && isPreviousPeriodEnabled,
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const useCrashFreeRate = (props: Props) => {
},
},
],
{staleTime: 0, enabled: isEnabled}
{staleTime: Infinity, enabled: isEnabled}
);

const isPreviousPeriodEnabled = shouldFetchPreviousPeriod({
Expand All @@ -89,7 +89,7 @@ const useCrashFreeRate = (props: Props) => {
},
],
{
staleTime: 0,
staleTime: Infinity,
enabled: isEnabled && isPreviousPeriodEnabled,
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const useReleaseCount = (props: Props) => {
},
},
],
{staleTime: 0, enabled: isEnabled}
{staleTime: Infinity, enabled: isEnabled}
);

const isPreviousPeriodEnabled = shouldFetchPreviousPeriod({
Expand All @@ -71,7 +71,7 @@ const useReleaseCount = (props: Props) => {
},
],
{
staleTime: 0,
staleTime: Infinity,
enabled: isEnabled && isPreviousPeriodEnabled,
}
);
Expand All @@ -97,7 +97,7 @@ const useReleaseCount = (props: Props) => {
},
],
{
staleTime: 0,
staleTime: Infinity,
enabled: isEnabled && isAllTimePeriodEnabled,
}
);
Expand Down

0 comments on commit 9e37e68

Please sign in to comment.