Commit 5e6bddc
fix(rtc): satisfy mypy strict and preserve track cleanup on unpublish race
Address two issues from review of the local_track_unpublished fix:
1. mypy strict (CI gate) flagged room.py: `pop(sid, None)` was assigned to
`lpublication`, which is also bound to `track_publications[sid]`
(non-optional LocalTrackPublication) in sibling branches of the same
method. mypy fixes the variable's type from that first binding and pushes
it as the expected return type into `pop`, selecting the
`pop(key, default: _VT) -> _VT` overload and rejecting None. Use a fresh
variable with `.get()` + conditional `del`, mirroring the existing
local_track_republished handler, which already passes the gate.
2. With the handler now removing the publication first in the common
ordering, unpublish_track's `pop(track_sid, None)` returned None and
skipped the `_track = None` cleanup, leaving a LocalTrackPublication
reference held by application code reporting a stale non-None track after
`await unpublish_track(...)` completed. Capture the publication reference
before the FFI round-trip so the track is cleared once unpublish
completes regardless of which path removes it from the dict.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 2dbb047 commit 5e6bddc
2 files changed
Lines changed: 20 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
784 | 784 | | |
785 | 785 | | |
786 | 786 | | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
787 | 794 | | |
788 | 795 | | |
789 | 796 | | |
| |||
799 | 806 | | |
800 | 807 | | |
801 | 808 | | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
806 | 812 | | |
807 | 813 | | |
808 | 814 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
737 | 737 | | |
738 | 738 | | |
739 | 739 | | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
745 | 745 | | |
746 | | - | |
747 | | - | |
748 | | - | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
749 | 750 | | |
750 | | - | |
751 | | - | |
752 | | - | |
| 751 | + | |
753 | 752 | | |
754 | 753 | | |
755 | 754 | | |
| |||
0 commit comments