Skip to content

fix: unsubscribe FFI queue when the room listen task ends#699

Merged
longcw merged 2 commits into
mainfrom
longc/fix-ffi-unsubscribe-on-eos
Jun 4, 2026
Merged

fix: unsubscribe FFI queue when the room listen task ends#699
longcw merged 2 commits into
mainfrom
longc/fix-ffi-unsubscribe-on-eos

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented Jun 3, 2026

When a room is disconnected remotely (e.g. the participant is removed), Room.disconnect() early-returns on not isconnected() and never unsubscribes the room's FFI event queue. The FFI receive thread keeps posting events to it, and once the event loop closes it logs error putting to queue: Event loop is closed.

Unsubscribe the FFI queue in a done callback on the listen task, so the subscription's lifetime matches its only consumer (_listen_task) regardless of how it ends — EOS, error, or cancellation. unsubscribe is idempotent, so the existing calls in disconnect() and __del__ stay harmless.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@longcw longcw merged commit 91f5a9e into main Jun 4, 2026
51 of 52 checks passed
@longcw longcw deleted the longc/fix-ffi-unsubscribe-on-eos branch June 4, 2026 00:56
@xianshijing-lk
Copy link
Copy Markdown
Contributor

sorry for being late on review, it looks good to me too. Thanks for fixing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants