Skip to content

Commit

Permalink
Merge pull request #120 from mattn/fix-goroutine-leak
Browse files Browse the repository at this point in the history
fix possibly goroutine leak
  • Loading branch information
mattn authored Jul 22, 2024
2 parents 3d04ee4 + 01d5005 commit 8d1bd80
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func (s *Server) doEvent(ctx context.Context, ws *WebSocket, request []json.RawM
// event deletion -- nip09
for _, tag := range evt.Tags {
if len(tag) >= 2 && tag[0] == "e" {
ctx, cancel := context.WithTimeout(ctx, time.Millisecond*200)
defer cancel()

// fetch event to be deleted
res, err := s.relay.Storage(ctx).QueryEvents(ctx, nostr.Filter{IDs: []string{tag[1]}})
if err != nil {
Expand All @@ -94,7 +97,7 @@ func (s *Server) doEvent(ctx context.Context, ws *WebSocket, request []json.RawM
exists := false
select {
case target, exists = <-res:
case <-time.After(time.Millisecond * 200):
case <-ctx.Done():
}
if !exists {
// this will happen if event is not in the database
Expand Down

0 comments on commit 8d1bd80

Please sign in to comment.