Does deleting a room automatically trigger the shu...
# ask-ai
r
Does deleting a room automatically trigger the shutdown hook?
t
Thanks for reaching out, Rithvik. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — good question about shutdown behavior. Yes — deleting a room automatically triggers the shutdown hook. When a room is deleted via the
delete_room
API, all participants (including agent sessions) are disconnected, which starts the session shutdown sequence; any shutdown hooks registered with
ctx.add_shutdown_callback()
run as part of that teardown. This applies whether you delete the room before or after calling
session.shutdown()
. Sources: Job lifecycle | LiveKit docs
r
It does not seem to be happening sometimes
t
Sorry that this is intermittent — I can help troubleshoot. A few quick clarifying questions so I can narrow the cause: 1. How are you deleting the room when the hook fails — via the
delete_room
API, an SDK call, or some other process? 2. Do you call
session.shutdown()
anywhere before/after deletion, or do you rely on deletion to trigger the session shutdown? 3. Is the behavior reproducible in certain environments (local, staging, production) or with certain room sizes/participant counts? 4. Do you see any errors or logs from the agent/service around the time of deletion (disconnects, timeouts, process exits)? If so, please share relevant log snippets and timestamps. 5. What LiveKit version and SDK/runtime are you running for the agent that registers
ctx.add_shutdown_callback()
? With those details I’ll suggest targeted checks and next steps (common causes include abrupt process termination, race conditions where the process exits before callbacks run, or deletion via a path that forces immediate disconnects).