Skip to content

ERROR "publisher data channel closed unexpectedly" on room delete shortly after session start (1.6.4) #6250

Description

@miguelmoralai

When a session is shut down and the room is deleted shortly after it is initialized (via delete_room_on_close=True), three ERROR-level logs are emitted during teardown:

ERROR livekit::rtc_engine::rtc_session:646:livekit::rtc_engine::rtc_session - publisher data channel '_reliable' closed unexpectedly
ERROR livekit::rtc_engine::rtc_session:646:livekit::rtc_engine::rtc_session - publisher data channel '_lossy' closed unexpectedly
ERROR livekit::rtc_engine::rtc_session:646:livekit::rtc_engine::rtc_session - publisher data channel '_data_track' closed unexpectedly

They appear right after the framework deletes the room:

INFO  deleting room on agent session close (disable via RoomInputOptions.delete_room_on_close=False)
ERROR ... publisher data channel '_reliable' closed unexpectedly
ERROR ... publisher data channel '_lossy' closed unexpectedly
ERROR ... publisher data channel '_data_track' closed unexpectedly

The call itself completes cleanly (shutdown callbacks run, post-call work succeeds). The data channels are closed because the room was deleted on purpose, so logging this at ERROR looks like a false positive during normal teardown.

Why it seems to happen

This appears to be a timing race during teardown: when ctx.shutdown() runs very early in the call, the room is deleted (server-side close of the data channels) before the session's local closed flag is set, so the new check at rtc_session.rs:646 (added in livekit/rust-sdks#1137) sees the channel close as unexpected. It is most reproducible when the session is shut down just a few seconds after the room is created.

Steps to reproduce

  1. Start an agent session.
  2. A few seconds after the room is initialized, call ctx.shutdown() with delete_room_on_close=True (default).
  3. Observe the three ERROR logs above during teardown.

Expected

A room deleted intentionally on session close should not log publisher data channel ... closed unexpectedly at ERROR level (e.g. suppress/downgrade when the close was initiated by us).

Versions

  • livekit-agents 1.6.4
  • livekit (rtc) 1.1.12

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions