[fix] bump livekit rtc 1.1.9 → 1.1.13 修 local_track_unpublished KeyError - #1
Closed
YJack0000 wants to merge 1 commit into
Closed
[fix] bump livekit rtc 1.1.9 → 1.1.13 修 local_track_unpublished KeyError#1YJack0000 wants to merge 1 commit into
YJack0000 wants to merge 1 commit into
Conversation
## AS IS - pin `livekit==1.1.9`,該版 `_on_room_event` 對 `local_track_unpublished` 直接做 `track_publications[sid]` 無防護查找 - `unpublish_track()` 的 FFI response 與同一條 queue 上的 `local_track_unpublished` RoomEvent 賽跑,response 先到就 KeyError - 生產環境每通電話 teardown(BackgroundAudioPlayer.aclose())都可能噴 ERROR + traceback ## TO BE - pin `livekit==1.1.13`,含 upstream livekit/python-sdks#692 的修正 (改為 `.get(sid)` 防護性查找 + 補上 `_track = None` 清理) - 對齊 upstream livekit/agents main 的 pin
Author
|
改走既有的 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the
local_track_unpublishedKeyError spam in production livekit-agent.Main-repo tracking issue: pathorsAI/pathors#1274
AS IS
Pin 是
livekit==1.1.9。該版Room._on_room_event對local_track_unpublished事件做無防護的 dict 查找(
rtc/room.py:739):這跟
LocalParticipant.unpublish_track()(rtc/participant.py:777)打架。unpublish_track在自己的 FFI response 回來後會先 pop 掉 publication:而 Rust FFI 同時往同一條 event queue 丟一個
local_track_unpublishedRoomEvent。兩者的處理順序不保證:response 先被處理時,RoomEvent 後到,
dict 裡已經沒有那個 sid,
_listen_task就整個 except 起來印 traceback。生產環境長這樣(每通電話 teardown 都可能出現):
觸發點就在這個 repo:
voice/background_audio.py:406,BackgroundAudioPlayer.aclose()收背景音 track 時呼叫
unpublish_track()。這是唯一會 unpublish 的地方,用法本身沒問題(跟 upstream 一致),純粹是踩到 SDK 的 race。
TO BE
Pin 改成
livekit==1.1.13,帶進 upstream livekit/python-sdks#692 的修正(issue livekit/python-sdks#681,1.1.11 起已修)。修法是防護性查找 +
補上 track reference 清理:
同時對齊 upstream
livekit/agentsmain 的 pin(也是livekit==1.1.13)。相容性檢查(1.1.9 → 1.1.13)
我把兩版 wheel 抓下來逐項比對過:
EventTypes事件移除__all__移除的 exportPacketTrailerFeature→ 更名FrameMetadataFeature;fork 與 app 都沒用到LocalTrackPublication.packet_trailer_featuresframe_metadata_features;沒有呼叫點create_audio_tracksignaturesource型別由AudioSource放寬成Union[AudioSource, PlatformAudioSource],positional 呼叫不變 → 本 repo 3 個呼叫點(background_audio.py:530、room_io/_output.py:67、avatar/_runner.py:108)全相容_token/_server_url/_rpc_handlers/_info)新增的是
PlatformAudio系列 API(AudioDeviceInfo/PlatformAudioSource等),純新增,不影響既有路徑。
影響
這個 KeyError 本身是良性的 —— 唯一後果是那次
local_track_unpublished事件沒 emit 出去,而本 repo 與 pathors app 都沒有任何地方監聽這個事件。
真正的成本是它污染 pathorsAI/pathors#1071 建立的 LiveKit error alert 訊號,
讓真正的錯誤更難被看見。
驗證
配套 PR(bump submodule pointer +
uv.lock)在主 repo,會等這支 merge 後指過去。