Skip to content

Commit

Permalink
fix: fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Aug 1, 2024
1 parent c0552de commit af0b75a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions node/pkg/dal/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func (c *ThreadSafeClient) WriteJSON(data any) error {
return nil
}

// even though readjson is not thread safe, it is expected not be called concurrently
// since the only place it is called is from `HandleWebsocket` inner for loop
func (c *ThreadSafeClient) ReadJSON(data any) error {
c.mu.Lock()
defer c.mu.Unlock()
if err := c.Conn.ReadJSON(&data); err != nil {
log.Error().Err(err).Msg("failed to read json msg")
return err
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/dal/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func HandleWebsocket(conn *websocket.Conn) {
var msg Subscription
if err = threadSafeClient.ReadJSON(&msg); err != nil {
log.Error().Err(err).Msg("failed to read message")
continue
return
}

if msg.Method == "SUBSCRIBE" {
Expand Down

0 comments on commit af0b75a

Please sign in to comment.