Coalesce in-flight fantasy analysis and harden refresh cache bypass - #284
Merged
sfreeman422 merged 2 commits intoSep 9, 2026
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix code based on review comments
Coalesce in-flight fantasy analysis and harden refresh cache bypass
Sep 9, 2026
sfreeman422
marked this pull request as ready for review
September 9, 2026 17:51
There was a problem hiding this comment.
🟢 Approval recommended
The changes are localized, align with the PR’s stated goals, and include targeted test coverage for the new cache/concurrency behaviors.
Pull request overview
This PR tightens “refresh” behavior for the fantasy overview by (1) preventing duplicate concurrent AI trade-analysis generations on the backend via in-flight request coalescing and (2) ensuring frontend refresh requests bypass intermediary/browser caches by explicitly using cache: 'no-store'.
Changes:
- Backend: added an in-flight promise map to reuse an ongoing
generateTradeAnalysis(...)for identical concurrent requests, while also deleting expired cached entries on access. - Frontend: refresh requests now pass
RequestInit.cache = 'no-store'alongside the existing?refresh=truequery param. - Tests: added/updated focused specs to validate refresh fetch options, stale cache eviction/regeneration, and concurrent-request coalescing.
File summaries
| File | Description |
|---|---|
| packages/frontend/src/pages/FantasyPage.spec.tsx | Asserts refresh fetch calls include { cache: 'no-store' }. |
| packages/frontend/src/hooks/useFantasy.ts | Passes { cache: 'no-store' } for refresh overview requests to force a network fetch. |
| packages/backend/src/fantasy/fantasy.service.ts | Coalesces concurrent analysis generation via analysisRequests and clears expired cache entries. |
| packages/backend/src/fantasy/fantasy.service.spec.ts | Adds test coverage for concurrent coalescing and expired-entry regeneration behavior. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Refresh requests in the fantasy overview path could still duplicate concurrent AI generations and might not bypass HTTP/browser caches despite
refresh=true. This PR closes both gaps in backend cache behavior and frontend refresh fetch semantics.Backend: analysis cache concurrency + stale-entry handling
analysisCache.getTradeAnalysis(...)now:Frontend: guaranteed network refresh
useFantasynow passcache: 'no-store'with the existing?refresh=trueURL to prevent intermediary/browser cache reuse.Coverage updates for new behavior
generate()invocation,cache: 'no-store'.