54b682a663
From audit doc-25 (Phase 2), Recommendation #2.
1.4 KiB
1.4 KiB
id, title, status, assignee, created_date, labels, dependencies, documentation, modified_files, priority, ordinal
| id | title | status | assignee | created_date | labels | dependencies | documentation | modified_files | priority | ordinal | |||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ML-190 | Skip redundant unsubscribe+resubscribe on same-record reconnect | To Do | 2026-05-19 08:42 |
|
|
|
low | 25000 |
Description
RecordActions.manage_subscription/2 unsubscribes the old record and subscribes the new record on every handle_params call. When LiveView reconnects to the same record (e.g., after a WebSocket drop within the reconnect grace period), it unsubscribes and resubscribes to the same topic. While harmless (Phoenix.PubSub deduplicates by PID), a same-record check would be a micro-optimization.
Fix: Add a guard: if socket.assigns[:record] && socket.assigns.record.id != new_id, do: Records.unsubscribe(...) — only unsubscribe when the record actually changes.
Source: Audit doc-25 (Phase 2), Recommendation #2.
Acceptance Criteria
- #1 manage_subscription/2 only calls unsubscribe when old record ID differs from new ID
- #2 Same-record reconnect skips unsubscribe+resubscribe entirely
- #3 All existing tests pass