-
Notifications
You must be signed in to change notification settings - Fork 70
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
Early-response API feedback #44
Comments
Testing out the new API myself, so might have some feedback down the line, but I think I've spotted a bug currently breaking the non-async command handler. Likely caused by this line: https://github.com/soxtoby/SlackNet/blob/master/SlackNet/Handlers/SlashCommandHandlerAsyncWrapper.cs#L12 I noticed that the I can report this elsewhere as well if need be. |
Thanks for the feedback. I've fixed the slash command response being passed along in v0.9.2. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
It's not very clear how this works now. Slack API says that it waits 3 seconds for an answer, which is plenty of time to do something with the event message. I would rely on Slack retry with exponential wait time mechanism described here
Even if it's a good practice to respond 200 OK asap, it seems there is an important risk currently if an event fails to be placed in a queue or similar for later processing. The 200 OK is returned regardless. The following handler would execute, but still a 200 OK would be returned.
The handlers should be awaited before sending 200 OK or error back to slack. It is up to the developer to make sure they are handled quickly and it's recommended they are queued for async processing. But it should wait for the handler to complete. |
I try to use this, but
Doesnt send? Regards, |
Hi @ezarzone, this problem is unrelated to the early-response API specifically, so I've responded in the other issue you've raised. Cheers. |
A common issue with the current handler API is that SlackNet waits for all of the handlers' work to complete before responding to Slack, which doesn't wait very long before showing errors in the UI. The v0.7 release includes an experimental API for responding to Slack before completing all the work a handler performs. This lets you implement a handler like this:
Eventually I want to replace the existing API, rather than having two parallel handler APIs, and so the goals are:
I'd appreciate any feedback or suggestions people may have.
Other options that were considered
Respond method on the input
Simpler than a Responder callback parameter, but I'm not sure it's obvious enough how to respond.
Append extra work to the return value
For handlers with a return value, this keeps the same method signature, which means zero upgrade pain. Doesn't work so well for handlers without a return value, like block action handlers. Having to split the extra work into another function isn't great, either.
Specific return type
This makes it really clear how to do more work after responding, but it's pretty ugly, and once again you need to split the extra work into another function.
Async enumerables
I really liked the elegance of this, but it's not clear that you're only meant to return one response, and development on older .NET Core/Framework versions with C# 7 is not straightforward.
Concerns with the current design
Responder
parameter, and callingrespond
instead of returning, which would be a pain if you have a lot of handlers. Could be mitigated with a code analyzer + fix.respond
multiple times?Responder
delegate is simple, but not very extensible. AnIResponder
interface would make the code slightly more verbose (responder.Respond()
instead of justrespond()
), but it would allow adding new response options in an obvious place. Delegates can have extension methods, which would cover most scenarios, but it might not be obvious enough that they're available.Once again, any feedback is appreciated. Everything in this API is in an
Experimental
namespace and marked asObsolete
, because I want to be able to make improvements before "releasing" it.The text was updated successfully, but these errors were encountered: