mirror of https://github.com/coder/coder.git
fix: avoid agent runLoop exiting due to ws ping (#8852)
This commit is contained in:
parent
f48e8dcf88
commit
b955c5fefc
|
@ -236,7 +236,9 @@ func (a *agent) runLoop(ctx context.Context) {
|
|||
if err == nil {
|
||||
continue
|
||||
}
|
||||
if errors.Is(err, context.Canceled) {
|
||||
if ctx.Err() != nil {
|
||||
// Context canceled errors may come from websocket pings, so we
|
||||
// don't want to use `errors.Is(err, context.Canceled)` here.
|
||||
return
|
||||
}
|
||||
if a.isClosed() {
|
||||
|
|
|
@ -204,7 +204,7 @@ func (c *Client) DERPMapUpdates(ctx context.Context) (<-chan DERPMapUpdate, io.C
|
|||
defer close(updates)
|
||||
defer close(updatesClosed)
|
||||
defer cancelFunc()
|
||||
defer conn.Close(websocket.StatusGoingAway, "Listen closed")
|
||||
defer conn.Close(websocket.StatusGoingAway, "DERPMapUpdates closed")
|
||||
for {
|
||||
var update DERPMapUpdate
|
||||
err := dec.Decode(&update.DERPMap)
|
||||
|
@ -240,7 +240,7 @@ func (c *Client) DERPMapUpdates(ctx context.Context) (<-chan DERPMapUpdate, io.C
|
|||
closeFunc: func() error {
|
||||
cancelFunc()
|
||||
<-pingClosed
|
||||
_ = conn.Close(websocket.StatusGoingAway, "Listen closed")
|
||||
_ = conn.Close(websocket.StatusGoingAway, "DERPMapUpdates closed")
|
||||
<-updatesClosed
|
||||
return nil
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue