fix: Don't use StatusAbnormalClosure (#4155)

This commit is contained in:
Kyle Carberry
2022-09-22 13:26:05 -05:00
committed by GitHub
parent 9e099b543f
commit a7ee8b31e0
17 changed files with 62 additions and 34 deletions

View File

@ -308,15 +308,15 @@ func (c *Client) DialWorkspaceAgentTailnet(ctx context.Context, logger slog.Logg
logger.Debug(ctx, "serving coordinator")
err = <-errChan
if errors.Is(err, context.Canceled) {
_ = ws.Close(websocket.StatusAbnormalClosure, "")
_ = ws.Close(websocket.StatusGoingAway, "")
return
}
if err != nil {
logger.Debug(ctx, "error serving coordinator", slog.Error(err))
_ = ws.Close(websocket.StatusAbnormalClosure, "")
_ = ws.Close(websocket.StatusGoingAway, "")
continue
}
_ = ws.Close(websocket.StatusAbnormalClosure, "")
_ = ws.Close(websocket.StatusGoingAway, "")
}
}()
err = <-first
@ -446,7 +446,7 @@ func (c *Client) AgentReportStats(
var req AgentStatsReportRequest
err := wsjson.Read(ctx, conn, &req)
if err != nil {
_ = conn.Close(websocket.StatusAbnormalClosure, "")
_ = conn.Close(websocket.StatusGoingAway, "")
return err
}
@ -460,7 +460,7 @@ func (c *Client) AgentReportStats(
err = wsjson.Write(ctx, conn, resp)
if err != nil {
_ = conn.Close(websocket.StatusAbnormalClosure, "")
_ = conn.Close(websocket.StatusGoingAway, "")
return err
}
}