Compare commits

..

1 Commits

Author SHA1 Message Date
9e95b1fd78 Handle nil value in client _sync 2026-04-20 10:35:36 -04:00

View File

@@ -445,16 +445,20 @@ function Client:_sync(options)
for _, kind in ipairs { "join", "invite", "leave" } do for _, kind in ipairs { "join", "invite", "leave" } do
local handle = self["_sync_handle_room__" .. kind] local handle = self["_sync_handle_room__" .. kind]
for room_id, room_data in pairs(response.rooms[kind]) do if response.rooms != nil then
self._log("sync: %s %s", kind, room_id) for room_id, room_data in pairs(response.rooms[kind]) do
-- XXX: Maybe this is abusing pcall() too much to allow handler self._log("sync: %s %s", kind, room_id)
-- code to bail and continue with the next room instead of -- XXX: Maybe this is abusing pcall() too much to allow handler
-- completely failing to sync. Dunno. -- code to bail and continue with the next room instead of
local ok, err = xpcall(handle, xpcall_add_traceback, self, room_id, room_data) -- completely failing to sync. Dunno.
if not ok then local ok, err = xpcall(handle, xpcall_add_traceback, self, room_id, room_data)
self._log("sync: Error handling '%s' event for room %s:\n%s", kind, room_id, err) if not ok then
self._log("sync: Event payload: %s", json.encode(room_data)) self._log("sync: Error handling '%s' event for room %s:\n%s", kind, room_id, err)
end self._log("sync: Event payload: %s", json.encode(room_data))
end
end
else
self._log("sync: Error syncing rooms (nil value)"
end end
end end
end end