-
-
Notifications
You must be signed in to change notification settings - Fork 69.2k
Bug: Discord message chunks delivered in reverse order #32743
Description
Bug Report
Describe the bug
When a long reply is automatically split into multiple chunks (via textChunkLimit / maxLinesPerMessage), the chunks sometimes arrive in Discord in reverse order. For example, a two-part reply where part 1 is "好,测一下:" and part 2 is "测试结果..." shows up in Discord with part 2 first, then part 1.
Expected behavior
Chunks should always arrive in the correct sequential order — part 1 first, part 2 second.
Root cause hypothesis
The chunks may be sent concurrently (e.g. Promise.all or parallel dispatch) rather than sequentially (await each send before the next). Discord API does not guarantee delivery order for concurrent requests, so even a small timing difference can cause reordering.
Reproduction
- Have an agent reply with a message that exceeds
textChunkLimit(2000 chars) ormaxLinesPerMessage(17 lines) - Observe the order of chunks in Discord — they may be reversed
Environment
- Channel: Discord
- Config: default chunk settings (
textChunkLimit: 2000,maxLinesPerMessage: 17)
Suggested fix
Send chunks sequentially: await the Discord API response for chunk N before sending chunk N+1.