fix: cancel journal read before closing stream - #175
Conversation
pilipilisbot
left a comment
There was a problem hiding this comment.
Approved. I checked the linked Sentry issue, the PR diff around _journal_stream_events, the stream_journal_lines cleanup path, whitespace with git diff --check, the focused regression tests locally in a temporary venv, and the PR CI checks.
The change cancels and awaits the outstanding journal read/shutdown tasks before calling aclose(), which addresses the async-generator-running race seen when Starlette cancels the SSE response. The regression coverage exercises both dashboard shutdown and client-disconnect cancellation, and I do not see a correctness or operational blocker.
Local verification: /tmp/gab-pr175-venv/bin/python -m pytest -q tests/test_backend.py::test_dashboard_journal_stream_cancels_pending_read_when_client_disconnects tests/test_backend.py::test_dashboard_journal_stream_exits_when_shutdown_is_signaled passed: 2 passed, 1 Starlette/httpx deprecation warning.
GitHub checks: dashboard, pytest (3.11), and pytest (3.12) are passing.
Summary
aclose()Tests
pytest -q tests/test_backend.py::test_dashboard_journal_stream_cancels_pending_read_when_client_disconnects tests/test_backend.py::test_dashboard_journal_stream_exits_when_shutdown_is_signaled(2 passed)Fixes gisce#28
Requested by: automated Sentry alert from
gisce-ti-sentry[bot](no human requester)