Skip to content

Commit a2b4abd

Browse files
committed
rpc: send nil on subscription Err channel when Client is closed
This change makes client subscriptions compatible with the new Subscription semantics introduced in the previous commit.
1 parent 6d5e100 commit a2b4abd

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎rpc/client.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ func newClientSubscription(c *Client, channel reflect.Value) *ClientSubscription
682682
// resubscription when the client connection is closed unexpectedly.
683683
//
684684
// The error channel receives a value when the subscription has ended due
685-
// to an error. The received error is ErrClientQuit if Close has been called
685+
// to an error. The received error is nil if Close has been called
686686
// on the underlying client and no other error has occurred.
687687
//
688688
// The error channel is closed when Unsubscribe is called on the subscription.
@@ -707,6 +707,9 @@ func (sub *ClientSubscription) quitWithError(err error, unsubscribeServer bool)
707707
sub.requestUnsubscribe()
708708
}
709709
if err != nil {
710+
if err == ErrClientQuit {
711+
err = nil // Adhere to subscription semantics.
712+
}
710713
sub.err <- err
711714
}
712715
})

0 commit comments

Comments
 (0)