Skip to content

Commit 9b33f7b

Browse files
discard notification replies if channel is closed
Sometimes, when closing the notifications channel, we could end up trying to reply to a notification after the channel was already closed. For example when changing the server address of a node. In that scenario, the goroutine never finished and attempted to reply to the notification.
1 parent f0a90a1 commit 9b33f7b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

daemon/ui/notifications.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (c *Client) getClientConfig() *protocol.ClientConfig {
6161
}
6262

6363
func (c *Client) handleActionChangeConfig(stream protocol.UI_NotificationsClient, ntf *protocol.Notification) {
64-
log.Info("[notification] Reloading configuration")
64+
log.Info("[notification] Reloading configuration, type: %d, id: %d", ntf.Type, ntf.Id)
6565
// Parse received configuration first, to get the new proc monitor method.
6666
newConf, err := config.Parse(ntf.Data)
6767
if err != nil {
@@ -328,6 +328,10 @@ func (c *Client) sendNotificationReply(stream protocol.UI_NotificationsClient, n
328328
reply.Data = fmt.Sprint(err)
329329
}
330330
if err := stream.Send(reply); err != nil {
331+
if err == io.EOF {
332+
log.Trace("[Notifications] sendNotificationReply, stream channel closed")
333+
return nil
334+
}
331335
log.Error("Error replying to notification, type: %d, id: %d, err: %s", nType, reply.Id, err)
332336
return err
333337
}

0 commit comments

Comments
 (0)