diff --git a/backend/fastrtc/utils.py b/backend/fastrtc/utils.py index 7d09723a..6cf3bb85 100644 --- a/backend/fastrtc/utils.py +++ b/backend/fastrtc/utils.py @@ -53,6 +53,8 @@ def __init__(self, msg: str = "Stream closed") -> None: class DataChannel(Protocol): + @property + def readyState(self) -> str: ... def send(self, message: str) -> None: ... @@ -192,7 +194,9 @@ async def player_worker_decode( and channel() ): set_additional_outputs(outputs) - cast(DataChannel, channel()).send(create_message("fetch_output", [])) + dc = cast(DataChannel, channel()) + if dc.readyState == "open": + dc.send(create_message("fetch_output", [])) if frame is None: if isinstance(outputs, CloseStream):