You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Room.disconnect delivers TerminatedException to active text stream collectors #964
When Room.disconnect() is called while incoming text streams are open, every open stream channel is closed with an exception cause (IncomingDataStreamManagerImpl.clearOpenStreams):
Because TextStreamReceiver.flow is channel.receiveAsFlow(), that exception is rethrown into whatever coroutine is collecting the receiver's flow. In our app the collectors run in a session-scoped coroutine, so a clean, client-initiated disconnect tears down the scope as an uncaught exception:
Session scope canceled with error: UnknownError(cause=StreamException$TerminatedException)
If a stream's header has arrived but its trailer has not yet been received at disconnect time (typical for in-progress transcription segments), this fires on every normal hang-up.
Have the remote participant publish to the topic continuously (e.g. live transcription).
Call room.disconnect() while a stream is open.
The collector throws StreamException.TerminatedException.
Expected behavior
One of:
A clean client-initiated disconnect closes stream channels without a cause (the same way handleStreamTrailer closes channels on normal completion), so collectors complete normally; or
The current behavior is the intended contract, and it's documented. Neither the text streams guide nor the API reference for TerminatedException ("Stream terminated before completion") currently says collectors will receive this on room disconnect.
Possibly related:#881 is the same pattern with StreamException$IncompleteException — stream-channel close causes escaping into consumer coroutines as fatal exceptions. A documented contract for stream error delivery would cover both.
Device Info:
LiveKit SDK version: 2.25.3 (behavior unchanged on main as of 2026-06-10)
changed the title [-]Room.disconnect() delivers StreamException.TerminatedException to active text stream collectors — intended behavior? Undocumented either way[/-][+]Room.disconnect() delivers StreamException.TerminatedException to active text stream collectors[/+]on Jun 11, 2026
changed the title [-]Room.disconnect() delivers StreamException.TerminatedException to active text stream collectors[/-][+]Room.disconnect delivers TerminatedException to active text stream collectors[/+]on Jun 11, 2026
Hey, so the behavior here is intended, and the documentation should be updated. Any errors that happen while receiving the stream will be propagated through the flow as well as readNext().
Activity
[-]Room.disconnect() delivers StreamException.TerminatedException to active text stream collectors — intended behavior? Undocumented either way[/-][+]Room.disconnect() delivers StreamException.TerminatedException to active text stream collectors[/+][-]Room.disconnect() delivers StreamException.TerminatedException to active text stream collectors[/-][+]Room.disconnect delivers TerminatedException to active text stream collectors[/+]davidliu commentedon Jun 11, 2026
Hey, so the behavior here is intended, and the documentation should be updated. Any errors that happen while receiving the stream will be propagated through the flow as well as readNext().