✨ feat: stream_measurements sends /app/streaming/stop on teardown #165

Merged
mat merged 1 commit from feat/ws-stop into main 2026-10-27 10:34:51 +00:00
Owner

Summary

 stream_measurements teardown (both modes)
-  finally: _close_ws(ws)            # STOMP DISCONNECT + close
+  finally: _close_stream(ws)         # SEND /app/streaming/stop (best-effort) first

The SPA explicitly stops the server-side stream session on teardown (SEND destination:/app/streaming/stop, empty body — docs/energy.comwatt.com/websocket-realtime.md), instead of leaving it to die with the socket. The client now mirrors that in both stream paths (plain and reconnect): before the STOMP DISCONNECT, it best-effort SENDs /app/streaming/stop. Best-effort because the socket may already be dead (server-side drop): the failure is swallowed and the DISCONNECT/close() teardown still runs. Handshake failures keep the plain _close_ws teardown — the stream never started, so there is nothing to stop.

Evidence

  • Before: teardown only sent the STOMP DISCONNECT frame; the server-side stream session was left running until the socket died.
  • After: 5 new tests — exact stop frame (SEND\ndestination:/app/streaming/stop\n\n\x00) sent before DISCONNECT on gen.close(), sent after natural stream end, silently swallowed on a dead socket, absent after a failed handshake, and sent in reconnect mode; pytest = 216 passed; mypy clean.

Merge Danger

Door: two-way — teardown-only change; revert restores DISCONNECT-only.

Blast Radius: low — one extra STOMP frame per stream teardown; no success-path or frame-parsing change.

Closes #101 (stacked on #164 — merge that first, then retarget to main)

## Summary ```diff stream_measurements teardown (both modes) - finally: _close_ws(ws) # STOMP DISCONNECT + close + finally: _close_stream(ws) # SEND /app/streaming/stop (best-effort) first ``` The SPA explicitly stops the server-side stream session on teardown (`SEND destination:/app/streaming/stop`, empty body — `docs/energy.comwatt.com/websocket-realtime.md`), instead of leaving it to die with the socket. The client now mirrors that in both stream paths (plain and reconnect): before the STOMP `DISCONNECT`, it best-effort SENDs `/app/streaming/stop`. Best-effort because the socket may already be dead (server-side drop): the failure is swallowed and the `DISCONNECT`/`close()` teardown still runs. Handshake failures keep the plain `_close_ws` teardown — the stream never started, so there is nothing to stop. ## Evidence - **Before:** teardown only sent the STOMP `DISCONNECT` frame; the server-side stream session was left running until the socket died. - **After:** 5 new tests — exact stop frame (`SEND\ndestination:/app/streaming/stop\n\n\x00`) sent before `DISCONNECT` on `gen.close()`, sent after natural stream end, silently swallowed on a dead socket, **absent** after a failed handshake, and sent in reconnect mode; `pytest` = **216 passed**; `mypy` clean. ## Merge Danger **Door:** two-way — teardown-only change; revert restores DISCONNECT-only. **Blast Radius:** low — one extra STOMP frame per stream teardown; no success-path or frame-parsing change. Closes #101 (stacked on #164 — merge that first, then retarget to main)
✨ feat: stream_measurements sends /app/streaming/stop on teardown (#101)
Some checks failed
Tests / forgejo-pytest (push) Has been cancelled
Tests / forgejo-pytest (pull_request) Has been cancelled
3b2f331477
mat changed target branch from feat/ws-ping to main 2026-10-27 10:34:24 +00:00
mat force-pushed feat/ws-stop from 3b2f331477
Some checks failed
Tests / forgejo-pytest (push) Has been cancelled
Tests / forgejo-pytest (pull_request) Has been cancelled
to bf8b8cb903
All checks were successful
Tests / forgejo-pytest (push) Successful in 43s
Tests / forgejo-pytest (pull_request) Successful in 43s
2026-10-27 10:34:42 +00:00
Compare
mat changed title from WIP: ✨ feat: stream_measurements sends /app/streaming/stop on teardown to ✨ feat: stream_measurements sends /app/streaming/stop on teardown 2026-10-27 10:34:48 +00:00
mat merged commit 172da30784 into main 2026-10-27 10:34:51 +00:00
mat deleted branch feat/ws-stop 2026-10-27 10:34:51 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mat/python-comwatt-client!165
No description provided.