bolt-js icon indicating copy to clipboard operation
bolt-js copied to clipboard

Slack assistant `assistant.userMessage` loops infinitely when given specific message

Open aku11i opened this issue 4 months ago • 5 comments

@slack/bolt version

4.4.0

Your App and Receiver Configuration

/** Initialization */
const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  appToken: process.env.SLACK_APP_TOKEN,
  socketMode: true,
  logLevel: LogLevel.DEBUG,
});

Node.js runtime version

v20 and v22

Steps to reproduce:

(I will share a repository with a reproducible case later.)

  1. Create an AI assistant app with slack create.
  2. Rewrite the assistant.userMessage handler so that it only posts a simple message.
  userMessage: async ({ message, say }) => {
    await say(`message received: ${message.ts} `);
  },
  1. Run the application by slack run
  2. Open assistant panel (or direct message) with the ai assistant.
  3. Copy the text below and send it exactly as written.
メンバーに対する上司フィードバックを記入します。一緒に手伝ってください。
2. そのメンバーに対する雑感(メンバーに対して思っていること、評価材料。なるべく多い方が良い)
情報が集まったら、対象メンバーへのフィードバックを新しい順に2つ取得してください。
最新の期間のフィードバックを記入します。一つ前の期間のフィードバックは(あれば)参考情報として使用します。
私のメンバーへの雑感をベースに、取得したフィードバックの情報を補完し、私からメンバーへの上司フィードバックを完成させてください。
<上司フィードバックの出力フォーマット>
## 選択したタイトルを満たしていると思う理由について、具体的な事象を元に記載ください
{メンバーへのフィードバックの内容を文章形式のプレーンテキストで記載する。}

Expected result:

The assistant should receive the assistant.userMessage event exactly once for the message I send.

Actual result:

The assistant receives the assistant.userMessage event over and over in an apparent infinite loop after a single message submission. The repeats can continue for several hours, and the same event may arrive 5–10 additional times.

Image

Additional context:

The shared text is the minimal message that still reproduces the problem. I confirmed this by trimming the original message one line at a time and observing the behavior.

Even if I rerun slack run while the issue is active, the app keeps receiving past events, which suggests the problem lies in Slack’s backend processing rather than this library.

The events can pause for more than 10 minutes and seem to stop, only to resume 20 minutes later. In some cases they continue for over two hours, so it’s hard to tell whether the stream has finished.

This happens both when running slack run locally in Socket Mode and in production on Amazon ECS via the Events API.

When the problem occurs, the thread title is always stuck on “New Assistant Thread.”.

Image

aku11i avatar Oct 06 '25 13:10 aku11i

Reproduction repository: https://github.com/aku11i/slack-issue-report-20251006

aku11i avatar Oct 06 '25 13:10 aku11i

👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.

github-actions[bot] avatar Nov 10 '25 00:11 github-actions[bot]

As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.

github-actions[bot] avatar Nov 24 '25 00:11 github-actions[bot]

Hey @aku11i! 👋 Thanks so much for sharing this, and apologies for not responding earlier!

I can confirm the message shared causes repeated events to be sent, and repeated responses from the app as you shared:

Image

From the debug logs of this attempt I notice that messages are both acknowledged as expected and that the incoming events aren't retries, but instead have separate event IDs:

  • Ev0A10NQQ29J
  • Ev0A0FNEL65D
  • Ev0A0V3BF5M4
  • Ev0A10N462VA
  • Ev0A0X4LG05Q

This is quite unexpected to me and I'm not sure if this is related to the contents of the message or if another issue might be causing this... Let's reopen this to continue investigations 🫡

Edit: Wanting to note that those event IDs were received over Socket Mode for the initial message and not other events.

zimeg avatar Dec 02 '25 01:12 zimeg

@zimeg Thank you for your response!

I've been able to work around this issue by having my application ignore duplicate events related to the posted message after the first one. However, I'm concerned that retrying the same message multiple times is putting unnecessary load on Slack's servers.

Additionally, if this is caused by a regex issue, there could be potential security vulnerabilities related to regular expressions like ReDoS.

I appreciate your investigation and look forward to understanding what's happening!

aku11i avatar Dec 02 '25 02:12 aku11i