Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Fix panic in QueryNextRoomHierarchyPage
Browse files Browse the repository at this point in the history
  • Loading branch information
S7evinK committed Nov 1, 2023
1 parent da7bca0 commit 96d6708
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions roomserver/internal/query/query_room_hierarchy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package query
import (
"context"
"encoding/json"
"errors"
"fmt"
"sort"

Expand Down Expand Up @@ -56,6 +57,12 @@ func (querier *Queryer) QueryNextRoomHierarchyPage(ctx context.Context, walker r
break
}

// If the context is canceled, we might still have discovered rooms
// return them to the client and let the client know there _may_ be more rooms.
if errors.Is(ctx.Err(), context.Canceled) {
break
}

// pop the stack
queuedRoom := unvisited[len(unvisited)-1]
unvisited = unvisited[:len(unvisited)-1]
Expand Down Expand Up @@ -112,6 +119,11 @@ func (querier *Queryer) QueryNextRoomHierarchyPage(ctx context.Context, walker r

pubRoom := publicRoomsChunk(ctx, querier, queuedRoom.RoomID)

if pubRoom == nil {
util.GetLogger(ctx).WithField("room_id", queuedRoom.RoomID).Debug("unable to get publicRoomsChunk")
continue
}

discoveredRooms = append(discoveredRooms, fclient.RoomHierarchyRoom{
PublicRoom: *pubRoom,
RoomType: roomType,
Expand Down

0 comments on commit 96d6708

Please sign in to comment.