-
Notifications
You must be signed in to change notification settings - Fork 676
Description
Packages:
Select all that apply:
-
@slack/web-api
-
@slack/rtm-api
-
@slack/webhooks
-
@slack/oauth
-
@slack/socket-mode
-
@slack/types
- I don't know
Reproducible in:
The Slack SDK version
"slack/web-api": "^7.9.1",
Node.js runtime version
v20.14.0
OS info
Microsoft Windows [Version 10.0.26100.3775]
Steps to reproduce:
- Post a message to a Slack channel, then 2 concurrent replies in that thread
- Delete the 2 messages at the same time
To that end, you can just run the following script:
const { WebClient } = require('@slack/web-api');
const client = new WebClient(process.env.SLACK_BOT_TOKEN);
const channelId = process.env.CHANNEL_ID;
(async function () {
const { ts: mainTs } = await client.chat.postMessage({ text: 'Test', channel: channelId });
const [{ ts: replyTs1 }, { ts: replyTs2 }] = await Promise.all([
client.chat.postMessage({ text: 'Reply 1', channel: channelId, thread_ts: mainTs }),
client.chat.postMessage({ text: 'Reply 2', channel: channelId, thread_ts: mainTs }),
]);
await Promise.all([
client.chat.delete({ channel: channelId, ts: replyTs1 }),
client.chat.delete({ channel: channelId, ts: replyTs2 }),
]);
})();
Note that this doesn't reproduce 100% of the time, but most of the time it does, so running it a handful of times should be enough.
Expected result:
Both replies are posted, then deleted, with no errors.
Actual result:
Both replies are indeed posted and then deleted, yet the 2nd of the chat.delete
calls returns:
{
status: 200,
statusText: 'OK',
headers: [...],
config: [...],
request: [...],
data: { ok: false, error: 'delete_failed' }
}
and consequently, the SDK throws an exception.
Adding a short delay between the 2 chat.postMessage
calls, or between the 2 chat.delete
ones, seems to make the error disappear - as far as I can tell, it only reproduces for messages fairly close to each other (up to maybe ~200ms apart), in the same thread, being deleted at the same time.