Skip to content

Fix repository scans not respecting cache policies in DAK selection#457

Merged
litlfred merged 2 commits intomainfrom
copilot/fix-456
Aug 1, 2025
Merged

Fix repository scans not respecting cache policies in DAK selection#457
litlfred merged 2 commits intomainfrom
copilot/fix-456

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Aug 1, 2025

Repository scans in the DAK selection page were triggering unnecessary rescans every time an authenticated user browsed the page, bypassing the 24-hour cache policy.

Root Cause

The issue was caused by cascading useCallback dependencies in DAKSelection.js:

  1. getMockRepositories and simulateEnhancedScanning were dependencies of the fetchRepositories useCallback
  2. These helper functions depended on effectiveProfile
  3. When the profile changed (even to the same value), the helper functions were recreated
  4. This caused fetchRepositories to be recreated, triggering the useEffect that calls it
  5. The cache check was bypassed, leading to unnecessary GitHub API calls

Solution

  • Used useRef to store the current profile, allowing helper functions to access it without depending on it
  • Made helper functions stable with empty or minimal dependencies
  • Removed helper functions from fetchRepositories dependencies
  • Added comprehensive documentation explaining the fix and ESLint disable rationale

Before vs After

Before: Every profile state change → helper functions recreated → fetchRepositories recreated → useEffect triggered → cache bypassed → unnecessary API call

After: Only actual profile/action changes → fetchRepositories recreated → cache properly checked → API call only when cache is stale/missing

Testing

  • Application builds successfully without linting errors
  • Existing repository cache integration tests pass
  • Manual verification shows cache policies are now respected

This ensures the 24-hour cache policy works as intended, preventing unnecessary GitHub API calls and improving performance for authenticated users browsing DAK repositories.

Fixes #456.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: litlfred <662242+litlfred@users.noreply.github.com>
@litlfred litlfred marked this pull request as ready for review August 1, 2025 19:51
@litlfred litlfred merged commit fc27d4e into main Aug 1, 2025
Copilot AI changed the title [WIP] repo scans dont seem to be respecting cache policies Fix repository scans not respecting cache policies in DAK selection Aug 1, 2025
Copilot AI requested a review from litlfred August 1, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

repo scans dont seem to be respecting cache policies

2 participants