{"action":"created","issue":{"url":"https://api.github.com/repos/nlopes/slack/issues/423","repository_url":"https://api.github.com/repos/nlopes/slack","labels_url":"https://api.github.com/repos/nlopes/slack/issues/423/labels{/name}","comments_url":"https://api.github.com/repos/nlopes/slack/issues/423/comments","events_url":"https://api.github.com/repos/nlopes/slack/issues/423/events","html_url":"https://github.com/nlopes/slack/issues/423","id":368905438,"node_id":"MDU6SXNzdWUzNjg5MDU0Mzg=","number":423,"title":"Disconnecting RTM does not close IncomingEvents channel","user":{"login":"adamrothman","id":662688,"node_id":"MDQ6VXNlcjY2MjY4OA==","avatar_url":"https://avatars1.githubusercontent.com/u/662688?v=4","gravatar_id":"","url":"https://api.github.com/users/adamrothman","html_url":"https://github.com/adamrothman","followers_url":"https://api.github.com/users/adamrothman/followers","following_url":"https://api.github.com/users/adamrothman/following{/other_user}","gists_url":"https://api.github.com/users/adamrothman/gists{/gist_id}","starred_url":"https://api.github.com/users/adamrothman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamrothman/subscriptions","organizations_url":"https://api.github.com/users/adamrothman/orgs","repos_url":"https://api.github.com/users/adamrothman/repos","events_url":"https://api.github.com/users/adamrothman/events{/privacy}","received_events_url":"https://api.github.com/users/adamrothman/received_events","type":"User","site_admin":false},"labels":[{"id":791809405,"node_id":"MDU6TGFiZWw3OTE4MDk0MDU=","url":"https://api.github.com/repos/nlopes/slack/labels/api%20breaking%20change","name":"api breaking change","color":"396acc","default":false},{"id":897581470,"node_id":"MDU6TGFiZWw4OTc1ODE0NzA=","url":"https://api.github.com/repos/nlopes/slack/labels/community%20decision","name":"community decision","color":"f2e360","default":false},{"id":959717015,"node_id":"MDU6TGFiZWw5NTk3MTcwMTU=","url":"https://api.github.com/repos/nlopes/slack/labels/documentation","name":"documentation","color":"b195f4","default":false},{"id":1115111919,"node_id":"MDU6TGFiZWwxMTE1MTExOTE5","url":"https://api.github.com/repos/nlopes/slack/labels/thinking","name":"thinking","color":"4507f2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-11T00:28:06Z","updated_at":"2018-11-04T01:18:01Z","closed_at":null,"author_association":"NONE","body":"My bot processes messages in a Goroutine written as follows:\r\n\r\n```go\r\nfunc (b *Bot) runSlackLoop(done chan bool) {\r\n\tlog.Println(\"Slack loop starting up\")\r\n\r\n\tgo b.rtm.ManageConnection()\r\n\r\n\tfor event := range b.rtm.IncomingEvents {\r\n\t\tswitch data := event.Data.(type) {\r\n\t\tcase *slack.MessageEvent:\r\n\t\t\t// Skip anything that isn't a DM from a human\r\n\t\t\tif !strings.HasPrefix(data.Channel, \"D\") || data.User == botSlackID || data.SubType == \"bot_message\" {\r\n\t\t\t\tcontinue\r\n\t\t\t}\r\n\r\n\t\t\tgo b.handleMessage(data)\r\n\t\t}\r\n\t}\r\n\r\n\tlog.Println(\"Slack loop shutting down\")\r\n\tdone <- true\r\n}\r\n```\r\n\r\nBut when I call `b.rtm.Disconnect()` from another Goroutine and do a blocking receive from the `done` channel, my program never exits.\r\n\r\nIs this intentional? If so, why? What's the recommended practice for shutting down a bot cleanly (i.e., making sure any received messages are processed before shutdown)?"},"comment":{"url":"https://api.github.com/repos/nlopes/slack/issues/comments/435633856","html_url":"https://github.com/nlopes/slack/issues/423#issuecomment-435633856","issue_url":"https://api.github.com/repos/nlopes/slack/issues/423","id":435633856,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTYzMzg1Ng==","user":{"login":"adamrothman","id":662688,"node_id":"MDQ6VXNlcjY2MjY4OA==","avatar_url":"https://avatars1.githubusercontent.com/u/662688?v=4","gravatar_id":"","url":"https://api.github.com/users/adamrothman","html_url":"https://github.com/adamrothman","followers_url":"https://api.github.com/users/adamrothman/followers","following_url":"https://api.github.com/users/adamrothman/following{/other_user}","gists_url":"https://api.github.com/users/adamrothman/gists{/gist_id}","starred_url":"https://api.github.com/users/adamrothman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamrothman/subscriptions","organizations_url":"https://api.github.com/users/adamrothman/orgs","repos_url":"https://api.github.com/users/adamrothman/repos","events_url":"https://api.github.com/users/adamrothman/events{/privacy}","received_events_url":"https://api.github.com/users/adamrothman/received_events","type":"User","site_admin":false},"created_at":"2018-11-04T01:18:01Z","updated_at":"2018-11-04T01:18:01Z","author_association":"NONE","body":"I think it makes sense to close the `IncomingEvents` channel _iff_ there will never be any more events sent on it. If the RTM is disconnected intentionally by the user (e.g. via `rtm.Disconnect()`), I think it's reasonable to close the channel. I guess that means you have to leave it open if the disconnect is unintentional, though, as a reconnect attempt may succeed and produce more events to deliver.\r\n\r\nCan you say a little more about the deadlock situation and what you have in mind for the refactor? How do you envision it impacting end users? Given that this library is still 0.x, I think it's acceptable to make backwards-incompatible changes as long as they are net improvements."}}
{"actor":{"display_login":"adamrothman"}}