Skip to content

Commit

Permalink
bugfix: fix panic when the room listener is called multiple times pri…
Browse files Browse the repository at this point in the history
…or to close()
  • Loading branch information
kegsay committed Feb 28, 2024
1 parent 3b13311 commit 6d5e39a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/api/rust/rust.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,13 @@ func (c *RustClient) TrySendMessage(t ct.TestLike, roomID, text string) (eventID
continue
}
if ev.Text == text && ev.ID != "" {
eventID = ev.ID
close(ch)
// if we haven't seen this event yet, assign the return arg and signal that
// the function should unblock. It's important to only close the channel once
// else this will panic on the 2nd call.
if eventID == "" {
eventID = ev.ID
close(ch)
}
}
}
return false
Expand Down

0 comments on commit 6d5e39a

Please sign in to comment.