Skip to content

Commit

Permalink
Merge pull request #1094 from lnxjedi/fix-timeout
Browse files Browse the repository at this point in the history
Honor deadman timer, fixes #1093
  • Loading branch information
kanata2 authored Sep 11, 2022
2 parents d197559 + 9521295 commit 6f5eda2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions socketmode/socket_mode_managed_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ func (smc *Client) run(ctx context.Context, connectionCount int) error {
}
}()

wg.Add(1)
// We don't wait on runMessageReceiver because it doesn't block on a select with the context,
// so we'd have to wait for the ReadJSON to time out, which can take a while.
go func() {
defer wg.Done()
defer cancel()

// The receiver reads WebSocket messages, and enqueues parsed Socket Mode requests to be handled by
Expand Down Expand Up @@ -162,7 +162,8 @@ func (smc *Client) run(ctx context.Context, connectionCount int) error {
return firstErr
}

// wg.Wait() finishes only after any of the above go routines finishes.
// wg.Wait() finishes only after any of the above go routines finishes and cancels the
// context, allowing the other threads to shut down gracefully.
// Also, we can expect firstErr to be not nil, as goroutines can finish only on error.
smc.Debugf("Reconnecting due to %v", firstErr)

Expand Down

0 comments on commit 6f5eda2

Please sign in to comment.