-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socketmode panic, write on closed channel #1125
Comments
I encounter the same problem 😔 |
@tiantangkuohai I think downgrade to 0.11.2 prevents the issue. |
Thanks for reporting. I'll confirm as soon as possible. |
Related: #1094 |
I understand the problem. I'd like to think a bit about a solution. |
Thanks @krzysztofjopekacaisoft @kanata2 . I use v0.11.2, and it works for me. Reconnect logs: I creates Client with below options |
…nel to close when it is finished, and consumer to see the close
Facing the same issue :(. I think awaiting of this goroutine will solve the problem) Yes, we need to wait for reading json from websocket, that can be too slow, but we can also run reading json asyncroniously and watch on ctx.Done() in select. I could implement it in PR, can you give me some feedback? now it is written in socket_mode_managed_conn.go:442 event := json.RawMessage{}
err := conn.ReadJSON(&event) But it could be something like that event := json.RawMessage{}
readJsonErr := make(chan error)
go func() {
readJsonErr <- conn.ReadJSON(&event)
}()
select {
case <-ctx.Done():
err = conn.Close() // we need to close connection to websocket
if err != nil {
// ....
}
return ctx.Error()
case err <- readJsonErr:
// future error handling
} What do you think? |
Created PR to resolve this problem, waiting for review and merging. |
Thanks! I'll review later. |
What happened
Looks like channel got closed:
slack/socketmode/socket_mode_managed_conn.go
Line 58 in 6f5eda2
before message got passed to the channel:
slack/socketmode/socket_mode_managed_conn.go
Line 485 in 6f5eda2
because we don't wait for completion:
slack/socketmode/socket_mode_managed_conn.go
Line 126 in 6f5eda2
Expected behavior
No panic
Steps to reproduce
Start socketmode slack client
reproducible code
https://github.com/slack-go/slack/blob/master/examples/socketmode/socketmode.go
Versions
The text was updated successfully, but these errors were encountered: