Skip to content
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

SocketmodeHandler RunEventLoopContext method #1162

Closed
lololozhkin opened this issue Jan 27, 2023 · 4 comments
Closed

SocketmodeHandler RunEventLoopContext method #1162

lololozhkin opened this issue Jan 27, 2023 · 4 comments

Comments

@lololozhkin
Copy link
Contributor

Description

socketmodeHandler.RunEventLoop() function doesn't allow to provide context for cancellation, so I couldn't find any way to gracefully stop event handling from websocket.. One of the ways is to close handler.Client.Events channel, but it is dangerous due to possible panics in channel writes, it also not the only channel in this struct, and it is not guaranteed that websocket connection will be gracefully shut down :(

In other abstractions library has methods like RunContext() and I think it is good idea to write such a method for socketmodeHandler.

I could do it myself, but I aware of not propper shutting down the client (I coudn't find any close(client.Events) channel)

@tylermmorton
Copy link

tylermmorton commented Feb 1, 2023

It looks like that logic is somewhat in place but context.TODO() is used instead of exposing a context to be passed. I'm also experiencing this issue and would be willing to put up a PR for the fix.

https://github.com/slack-go/slack/blob/master/socketmode/socket_mode_managed_conn.go#L33

@dblbirdie
Copy link

Being able to pass a cancellable context is exactly what I am looking for. I would highly appreciate any effort in implementing this.

@lololozhkin
Copy link
Contributor Author

Made pr with requested functionality, waiting for pull request to be approved.

@kanata2
Copy link
Member

kanata2 commented Apr 15, 2023

Resolved by #1169

@kanata2 kanata2 closed this as completed Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants