Skip to content

Commit

Permalink
fix: skip empty message (#2352)
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai authored Jan 17, 2025
1 parent 8bfe13f commit 5b40c6a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions node/pkg/wss/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,17 @@ func (ws *WebsocketHelper) Run(ctx context.Context, router func(context.Context,
log.Error().Err(err).Str("endpoint", ws.Endpoint).Msg("error reading from websocket")
break innerLoop
}

ws.lastMessageTime = time.Now()

go func(context.Context, map[string]any) {
routerErr := router(ctx, data)
if routerErr != nil {
log.Warn().Err(routerErr).Str("endpoint", ws.Endpoint).Msg("error processing websocket message")
}
}(ctx, data)
if len(data) != 0 {
go func(context.Context, map[string]any) {
routerErr := router(ctx, data)
if routerErr != nil {
log.Warn().Err(routerErr).Str("endpoint", ws.Endpoint).Msg("error processing websocket message")
}
}(ctx, data)
}
}
}
ws.Close()
Expand Down Expand Up @@ -228,5 +231,10 @@ func defaultReader(ctx context.Context, conn *websocket.Conn) (map[string]interf
if err != nil {
return nil, err
}

if len(data) == 0 {
return nil, nil
}

return data, nil
}

0 comments on commit 5b40c6a

Please sign in to comment.