@@ -281,10 +281,12 @@ func (c *Client) DialWorkspaceAgentTailnet(ctx context.Context, logger slog.Logg
281
281
CompressionMode : websocket .CompressionDisabled ,
282
282
})
283
283
if errors .Is (err , context .Canceled ) {
284
+ _ = ws .Close (websocket .StatusAbnormalClosure , "" )
284
285
return
285
286
}
286
287
if err != nil {
287
288
logger .Debug (ctx , "failed to dial" , slog .Error (err ))
289
+ _ = ws .Close (websocket .StatusAbnormalClosure , "" )
288
290
continue
289
291
}
290
292
sendNode , errChan := tailnet .ServeCoordinator (websocket .NetConn (ctx , ws , websocket .MessageBinary ), func (node []* tailnet.Node ) error {
@@ -294,10 +296,12 @@ func (c *Client) DialWorkspaceAgentTailnet(ctx context.Context, logger slog.Logg
294
296
logger .Debug (ctx , "serving coordinator" )
295
297
err = <- errChan
296
298
if errors .Is (err , context .Canceled ) {
299
+ _ = ws .Close (websocket .StatusAbnormalClosure , "" )
297
300
return
298
301
}
299
302
if err != nil {
300
303
logger .Debug (ctx , "error serving coordinator" , slog .Error (err ))
304
+ _ = ws .Close (websocket .StatusAbnormalClosure , "" )
301
305
continue
302
306
}
303
307
}
@@ -423,6 +427,7 @@ func (c *Client) AgentReportStats(
423
427
var req AgentStatsReportRequest
424
428
err := wsjson .Read (ctx , conn , & req )
425
429
if err != nil {
430
+ _ = conn .Close (websocket .StatusAbnormalClosure , "" )
426
431
return err
427
432
}
428
433
@@ -436,6 +441,7 @@ func (c *Client) AgentReportStats(
436
441
437
442
err = wsjson .Write (ctx , conn , resp )
438
443
if err != nil {
444
+ _ = conn .Close (websocket .StatusAbnormalClosure , "" )
439
445
return err
440
446
}
441
447
}
0 commit comments