Files
amethyst/commons
Claude c75c7c5599 fix(audio-rooms): VM catalog/buffering lifecycle leaks (audit #1-4)
Four related state-leak bugs surfaced by the new-interface audit:

  1. fetchSpeakerCatalog launched a fire-and-forget coroutine that
     wasn't tracked per-pubkey. With the wrapper's re-issuing
     handle the catalog subscription survives session swaps —
     and a removed speaker's collector kept re-adding the
     catalog map entry on every emission. Fix: per-pubkey job map
     (catalogJobs); cancel on closeSubscription before dropping
     the map entry.

  2. teardown() cleared activeSpeakers / speakingNow / announces
     but not _speakerCatalogs. Stale catalog data accreted
     across reconnects + room swaps. Fix: cancel every catalog
     job and reset the map alongside _announcedSpeakers.

  3. teardown()'s _uiState.copy(...) reset activeSpeakers and
     speakingNow but not connectingSpeakers. The pre-roll spinner
     could persist on stale pubkeys after a disconnect. Fix:
     include connectingSpeakers in the same copy.

  4. fetchSpeakerCatalog ran BEFORE the abandoned-subscription
     re-check in openSubscription, so a removed speaker's catalog
     subscription opened anyway. Fix: move the catalog kick-off
     to after the re-check + after slot.attach (the catalog needs
     a confirmed-attached audio slot to be cancellable via
     closeSubscription).
2026-04-27 02:24:22 +00:00
..