faint-arm-51818
12/08/2025, 2:06 PMtall-airline-16756
12/08/2025, 2:06 PMtall-airline-16756
12/08/2025, 2:07 PMctx.add_shutdown_callback() are stored and run when the session ends, but the framework does not enforce a specific execution order. Design your callbacks so they do not depend on one another.
Two additional facts to note:
• All shutdown callbacks must complete within the default 60-second timeout, after which the process is forcefully terminated.
• You can adjust that timeout via the shutdown_process_timeout parameter in agent server options.
Would you like an example pattern for making callbacks order-independent or help adjusting the timeout?
Sources: Job lifecycle | LiveKit docsfaint-arm-51818
12/08/2025, 2:08 PMtall-airline-16756
12/08/2025, 2:08 PMctx.add_shutdown_callback() execute during the shutdown phase (after your entrypoint returns or ctx.shutdown() is triggered), and must finish within the shutdown timeout (default 60s, configurable via shutdown_process_timeout).
Sources: Job lifecycle | LiveKit docsfaint-arm-51818
12/08/2025, 2:15 PMtall-airline-16756
12/08/2025, 2:15 PMasyncio.Event, write to a shared coordinator, or resolve a Future). Then register one shutdown callback that waits for those signals and runs final cleanup (ensure you handle timeouts so the overall shutdown stays within shutdown_process_timeout).
• Consolidate dependent cleanup into one callback so ordering and finalization are deterministic.
If you tell me which language/runtime you’re using (Python asyncio, Node, etc.), I can provide a short example implementing one of these patterns.