Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/src/stores/room-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export function createRoomStore(deps: RoomStoreDeps) {

function cleanupRoomResources(taskId: string): void {
taskGateways.delete(taskId);
verifyInFlight.delete(taskId);
}

function updateRoom(
Expand Down Expand Up @@ -116,6 +117,7 @@ export function createRoomStore(deps: RoomStoreDeps) {
message: prompt,
});
if (!res.ok) {
cleanupRoomResources(taskId);
return false;
}
Comment on lines 119 to 122

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When initConductor fails to create a session, the room is left in the store's rooms state with status: 'active' and conductorReady: false. This leads to an inconsistent state where a failed room is treated as active. We should remove the room from the store's state to maintain consistency.

Suggested change
if (!res.ok) {
cleanupRoomResources(taskId);
return false;
}
if (!res.ok) {
cleanupRoomResources(taskId);
set((s) => {
const nextRooms = { ...s.rooms };
delete nextRooms[taskId];
return { rooms: nextRooms };
});
return false;
}


Expand All @@ -126,6 +128,7 @@ export function createRoomStore(deps: RoomStoreDeps) {
return true;
} catch (err) {
console.warn('[room-store] initConductor failed:', err);
cleanupRoomResources(taskId);
return false;
}
Comment on lines 129 to 133

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When initConductor throws an error, the room is left in the store's rooms state with status: 'active' and conductorReady: false. We should remove the room from the store's state to maintain consistency.

      } catch (err) {
        console.warn('[room-store] initConductor failed:', err);
        cleanupRoomResources(taskId);
        set((s) => {
          const nextRooms = { ...s.rooms };
          delete nextRooms[taskId];
          return { rooms: nextRooms };
        });
        return false;
      }

},
Expand Down
Loading