Skip to content

fix: prevent duplicate SSE events at connect - #1229

Merged
feder-cr merged 5 commits into
feder-cr:mainfrom
Iams4kura:bugfix/sse-replay-live-boundary-20260905t160146z
Sep 6, 2026
Merged

fix: prevent duplicate SSE events at connect#1229
feder-cr merged 5 commits into
feder-cr:mainfrom
Iams4kura:bugfix/sse-replay-live-boundary-20260905t160146z

Conversation

@Iams4kura

Copy link
Copy Markdown
Contributor

Summary

  • Fixes: An event emitted after /chat/events subscribes but before its StreamingResponse body starts is sent once as replay and again as live, producing duplicate conversation rows.
  • Root cause: The listener queue is registered when the endpoint runs, but the history snapshot is delayed until the response generator first iterates, so an intervening event enters both history and the already-subscribed queue.

Regression evidence

  • Before: .venv/bin/python -m pytest -q tests/test_web_service.py::test_an_event_after_subscription_is_delivered_once_as_live exited 1

  • After: .venv/bin/python -m pytest -q tests/test_web_service.py::test_an_event_after_subscription_is_delivered_once_as_live exited 0

Verification

  • .venv/bin/python -m pytest -q tests/test_web_service.py
  • .venv/bin/python -m pytest -q
  • .venv/bin/python scripts/check_english_only.py --selftest && .venv/bin/python scripts/check_english_only.py
  • .venv/bin/python scripts/check_content.py --selftest && .venv/bin/python scripts/check_content.py
  • AIHAWK_CHECK_VERSION=1 .venv/bin/python -m pytest -q tests/test_version_is_not_taken.py
  • .venv/bin/python -m build --wheel; install the wheel in a clean virtual environment; run aihawk --help and import shipped modules

Scope

  • 3 files changed, +38 / -2 lines

@feder-cr
feder-cr merged commit 6244951 into feder-cr:main Sep 6, 2026
10 checks 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.

2 participants