Skip to content

Fix PriceCache.remove() not bumping version counter - #8

Merged
luiv-engineer merged 1 commit into
mainfrom
fix/price-cache-remove-version-bump
Sep 11, 2026
Merged

luiv-engineer merged 1 commit into
mainfrom
fix/price-cache-remove-version-bump

Conversation

@luiv-engineer

Copy link
Copy Markdown
Owner

Summary

  • PriceCache.remove() dropped a ticker without incrementing the _version counter 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.
  • Fix increments _version in remove(), guarded on whether a ticker was actually present so a no-op removal doesn't trigger a wasted SSE push.
  • Added test_remove_increments_version and test_remove_nonexistent_does_not_bump_version regression tests.
  • Added 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 passing
  • uv run --extra dev ruff check app/ tests/ → clean
  • Manually reproduced the last-ticker-removal scenario before/after the fix: version froze at 5 before the fix, now advances 5→6 immediately on removal.

🤖 Generated with Claude Code

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
@luiv-engineer
luiv-engineer merged commit edf4350 into main Sep 11, 2026
1 check passed
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.

1 participant