slackapi / node-slack-interactive-messages

Slack Buttons, Menus, and Dialogs made simpler for Node
MIT License
133 stars 41 forks source link

queue all calls to `respond()` by default #38

Closed aoberoi closed 5 years ago

aoberoi commented 6 years ago

Description

Currently, if you call respond() twice successively, there is no ordering guarantee on how the messages in Slack will update. If this is within an interactive message (button or menu), one call will overwrite the other but its a race condition. If its within a dialog submission (or a button or menu using the replace_original: false argument) then two messages will be created but in an arbitrary order.

The only way to rely on the ordering would be to wait on the first call's HTTP response to complete before sending the second call. This can be done by the developer once the return value of respond() is specified (#37), but its still not intuitive.

We can implement a queue with a max concurrency of 1 in the adapter such that calls to respond() are serially sent to Slack. This would result in more intuitive behavior. One recommendation for implementing this queue is the p-queue package (it's also used in @slack/client).

It may also be useful to add an optional parameter that skips the queue and sends the request as soon as possible.

Requirements

shaydewael commented 5 years ago

https://github.com/slackapi/node-slack-sdk/issues/824