From ecbd4244120521b3828aeacbd6daf79060713284 Mon Sep 17 00:00:00 2001 From: yayayahei Date: Sun, 7 Sep 2025 23:00:07 +0800 Subject: [PATCH] #141 Update ws/client.go listen ctx cancel when start client --- ws/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ws/client.go b/ws/client.go index 04c7ead5..b3653c20 100644 --- a/ws/client.go +++ b/ws/client.go @@ -122,7 +122,13 @@ func (c *Client) Start(ctx context.Context) (err error) { } } go c.pingLoop(ctx) - select {} + <-ctx.Done() + c.disconnect(ctx) + err = ctx.Err() + if err == context.Canceled { + err = nil + } + return } func (c *Client) connect(ctx context.Context) (err error) {