File tree 1 file changed +17
-3
lines changed
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -1285,9 +1285,23 @@ func (api *API) Close() error {
1285
1285
api .derpCloseFunc ()
1286
1286
}
1287
1287
1288
- api .WebsocketWaitMutex .Lock ()
1289
- api .WebsocketWaitGroup .Wait ()
1290
- api .WebsocketWaitMutex .Unlock ()
1288
+ wsDone := make (chan struct {})
1289
+ timer := time .NewTimer (10 * time .Second )
1290
+ defer timer .Stop ()
1291
+ go func () {
1292
+ api .WebsocketWaitMutex .Lock ()
1293
+ defer api .WebsocketWaitMutex .Unlock ()
1294
+ api .WebsocketWaitGroup .Wait ()
1295
+ close (wsDone )
1296
+ }()
1297
+ // This will technically leak the above func if the timer fires, but this is
1298
+ // maintly a last ditch effort to un-stuck coderd on shutdown. This
1299
+ // shouldn't affect tests at all.
1300
+ select {
1301
+ case <- wsDone :
1302
+ case <- timer .C :
1303
+ api .Logger .Warn (api .ctx , "websocket shutdown timed out after 10 seconds" )
1304
+ }
1291
1305
1292
1306
api .dbRolluper .Close ()
1293
1307
api .metricsCache .Close ()
You can’t perform that action at this time.
0 commit comments