Fix PriceCache.remove() not bumping version counter - #8
Merged
Merged
Conversation
PriceCache.remove() silently dropped a ticker from the cache without incrementing the version counter that the SSE endpoint uses to decide when to push a new payload. Practical effect: removing the last tracked ticker (empty watchlist) froze the version counter forever, so already-connected SSE clients kept serving the stale, now-deleted ticker indefinitely; for the Massive source (15s+ poll interval) any removal lagged an extra poll cycle before disappearing from the stream. - cache.py: increment _version in remove(), guarded on whether a ticker was actually present so no-op removals don't trigger a wasted SSE push. - test_cache.py: add test_remove_increments_version and test_remove_nonexistent_does_not_bump_version. - planning/MARKET_DATA_REVIEW.md: comprehensive review of the market data backend (verifies prior review's fixes, full test/lint/coverage run, this bug's discovery + fix, and remaining recommendations). 75/75 tests pass, ruff clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ww15Nu9BvuE18N8zCFtGCW
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.
Summary
PriceCache.remove()dropped a ticker without incrementing the_versioncounter the SSE endpoint uses to decide when to push a new payload. Practical effect: removing the last tracked ticker (empty watchlist) froze the version counter forever, so already-connected SSE clients kept serving the stale, now-deleted ticker indefinitely; for the Massive source (15s+ poll interval) any removal lagged an extra poll cycle before disappearing from the stream._versioninremove(), guarded on whether a ticker was actually present so a no-op removal doesn't trigger a wasted SSE push.test_remove_increments_versionandtest_remove_nonexistent_does_not_bump_versionregression tests.planning/MARKET_DATA_REVIEW.md: a full code review of the market data backend (re-verifies the prior archived review's fixes, fresh test/lint/coverage run, this bug's discovery + fix, and remaining recommendations).Test plan
uv run --extra dev pytest -v→ 75/75 passinguv run --extra dev ruff check app/ tests/→ clean🤖 Generated with Claude Code