Skip to content

Commit 612c8bd

Browse files
authored
add missing logs for DisconnectServerError cases (#417)
1 parent 3f2bf3c commit 612c8bd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ func (c *Client) Unsubscribe(ch string, unsubscribe ...Unsubscribe) {
895895

896896
err := c.unsubscribe(ch, unsub, nil)
897897
if err != nil {
898+
c.node.logger.log(newLogEntry(LogLevelError, "error unsubscribe", map[string]any{"channel": ch, "user": c.user, "client": c.uid, "error": err.Error()}))
898899
go c.Disconnect(DisconnectServerError)
899900
return
900901
}
@@ -1387,6 +1388,7 @@ func (c *Client) expire() {
13871388
_ = c.close(t)
13881389
return
13891390
default:
1391+
c.node.logger.log(newLogEntry(LogLevelError, "unexpected error from refresh handler", map[string]any{"user": c.user, "client": c.uid, "error": err.Error()}))
13901392
_ = c.close(DisconnectServerError)
13911393
return
13921394
}
@@ -2791,6 +2793,7 @@ func (c *Client) subscribeCmd(req *protocol.SubscribeRequest, reply SubscribeRep
27912793
if !ok || c.status == statusClosed {
27922794
c.mu.Unlock()
27932795
c.pubSubSync.StopBuffering(channel)
2796+
c.node.logger.log(newLogEntry(LogLevelError, "client closed or unsubscribed before adding subscription", map[string]any{"channel": channel, "user": c.user, "client": c.uid}))
27942797
ctx.disconnect = &DisconnectServerError
27952798
return ctx
27962799
}
@@ -2813,6 +2816,7 @@ func (c *Client) subscribeCmd(req *protocol.SubscribeRequest, reply SubscribeRep
28132816
if !ok || c.status == statusClosed {
28142817
c.mu.Unlock()
28152818
c.pubSubSync.StopBuffering(channel)
2819+
c.node.logger.log(newLogEntry(LogLevelError, "client closed or unsubscribed after adding subscription", map[string]any{"channel": channel, "user": c.user, "client": c.uid}))
28162820
ctx.disconnect = &DisconnectServerError
28172821
return ctx
28182822
}
@@ -3132,6 +3136,7 @@ func (c *Client) handleInsufficientStateDisconnect() {
31323136
func (c *Client) handleAsyncUnsubscribe(ch string, unsub Unsubscribe) {
31333137
err := c.unsubscribe(ch, unsub, nil)
31343138
if err != nil {
3139+
c.node.logger.log(newLogEntry(LogLevelError, "error async unsubscribing", map[string]any{"channel": ch, "user": c.user, "client": c.uid, "error": err.Error()}))
31353140
_ = c.close(DisconnectServerError)
31363141
return
31373142
}

0 commit comments

Comments
 (0)