I upgraded the livekit sdk and now im facing error...
# ask-ai
s
I upgraded the livekit sdk and now im facing error deleting the room
t
Thanks for reaching out, Abdullah. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m helping with the error you see when deleting a room after upgrading the LiveKit SDK. I need a few details to diagnose this quickly: • The exact error message or full stack trace you’re getting. • Which LiveKit SDK you upgraded (from version X to version Y) and which language (Node, Go, Python, Web, Android, iOS). • The code snippet you use to delete the room. • Whether you call the server-side DeleteRoom API or attempt deletion from a client SDK. • Confirm the token/grant you use includes the roomAdmin permission. If you share those, I’ll identify likely causes (permission mismatch, breaking change in the SDK, API differences) and provide concrete steps to fix it. Sources: Managing participants | LiveKit docs
s
ERROR livekit.agents unknown error while deleting room {"pid": 38955, "job_id": "AJ_VXVccR8gejvY", "room_id": "RM_gEQmsKvGrorV"} Traceback (most recent call last): File "/home/abdullah/Desktop/voice-ai-multiagent-backend/.venv/lib/python3.10 /site-packages/livekit/agents/job.py", line 413, in _delete_room await self.api.room.delete_room(api.DeleteRoomRequest(room=self._room.name)) File "/home/abdullah/Desktop/voice-ai-multiagent-backend/.venv/lib/python3.10 /site-packages/livekit/api/room_service.py", line 108, in delete_room return await self._client.request( File "/home/abdullah/Desktop/voice-ai-multiagent-backend/.venv/lib/python3.10 /site-packages/livekit/api/twirp_client.py", line 121, in request async with self._session.post( File "/home/abdullah/Desktop/voice-ai-multiagent-backend/.venv/lib/python3.10 /site-packages/aiohttp/client.py", line 1469, in aenter self._resp: _RetType = await self._coro File "/home/abdullah/Desktop/voice-ai-multiagent-backend/.venv/lib/python3.10 /site-packages/aiohttp/client.py", line 517, in _request raise RuntimeError("Session is closed") RuntimeError: Session is closed
t
Thanks — I’m responding about the RuntimeError "Session is closed" you see when deleting a room. This error shows the HTTP/Twirp client session was already closed when the SDK tried to post the DeleteRoom request. Common causes and steps to diagnose/fix: 1. Confirm where deletion runs • Are you calling
delete_room
from inside a long‑running background job or after shutting down your app’s aiohttp session? If the app closes its HTTP session or event loop before the delete call, you’ll get this error. 1. Ensure the LiveKit client/session is open when calling delete • Keep the LiveKit/twirp client or underlying aiohttp session alive until the delete completes. • If you create a client per job, create it just before the request and ensure you
await
the delete before closing the session. 1. Check your SDK usage after upgrade • If the upgraded SDK changed client lifecycle (constructor, async init, or close behavior), adjust code to match the new pattern (initialize client/session and avoid premature
close()
). • If you call any global shutdown/cleanup in finally blocks or signal handlers, ensure the delete runs before that cleanup. 1. Minimal code suggestions • Create and use the client inside the coroutine that performs the delete, then close it after the call completes. • Example pattern: a. Initialize client/session b.
await client.room.delete_room(...)
c. Close client/session 1. If delete runs concurrently • If multiple tasks share a single client/session, avoid one task closing the session while another is still using it. Use a single owner to close, or use an async lock to serialize close vs. use. Next step: please share one of the following so I can give a precise code fix: • The code snippet around client/session creation and where you call
delete_room
, or • Which Python LiveKit SDK version you upgraded from/to and whether you changed client lifecycle code. Would you like an example adjustment based on your snippet?