Skip to content

Commit

Permalink
added comment
Browse files Browse the repository at this point in the history
  • Loading branch information
barkyq authored and fiatjaf committed Jan 19, 2023
1 parent 82e4174 commit d7750ad
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,14 @@ func (s *Server) handleWebsocket(w http.ResponseWriter, r *http.Request) {
if advancedQuerier != nil {
advancedQuerier.AfterQuery(events, filter)
}

// this block should not trigger if the SQL query accounts for filter.Limit
// other implementations may be broken, and this ensures the client
// won't be bombarded.
if filter.Limit > 0 && len(events) > filter.Limit {
events = events[0:filter.Limit]
}

for _, event := range events {
ws.WriteJSON([]interface{}{"EVENT", id, event})
}
Expand Down

0 comments on commit d7750ad

Please sign in to comment.