@@ -317,10 +317,11 @@ func (c *Client) DialWorkspaceAgent(dialCtx context.Context, agentID uuid.UUID,
317
317
return nil , xerrors .Errorf ("parse url: %w" , err )
318
318
}
319
319
closedCoordinator := make (chan struct {})
320
- firstCoordinator := make (chan error )
320
+ // Must only ever be used once, send error OR close to avoid
321
+ // reassignment race. Buffered so we don't hang in goroutine.
322
+ firstCoordinator := make (chan error , 1 )
321
323
go func () {
322
324
defer close (closedCoordinator )
323
- firstCoordinator := firstCoordinator // Shadowed so it can be reassigned outside goroutine.
324
325
isFirst := true
325
326
for retrier := retry .New (50 * time .Millisecond , 10 * time .Second ); retrier .Wait (ctx ); {
326
327
options .Logger .Debug (ctx , "connecting" )
@@ -370,10 +371,11 @@ func (c *Client) DialWorkspaceAgent(dialCtx context.Context, agentID uuid.UUID,
370
371
return nil , xerrors .Errorf ("parse url: %w" , err )
371
372
}
372
373
closedDerpMap := make (chan struct {})
373
- firstDerpMap := make (chan error )
374
+ // Must only ever be used once, send error OR close to avoid
375
+ // reassignment race. Buffered so we don't hang in goroutine.
376
+ firstDerpMap := make (chan error , 1 )
374
377
go func () {
375
378
defer close (closedDerpMap )
376
- firstDerpMap := firstDerpMap // Shadowed so it can be reassigned outside goroutine.
377
379
isFirst := true
378
380
for retrier := retry .New (50 * time .Millisecond , 10 * time .Second ); retrier .Wait (ctx ); {
379
381
options .Logger .Debug (ctx , "connecting to server for derp map updates" )
0 commit comments