Bug Description
When using the debounce or queue concurrency strategy, Attachment.fetchData closures are lost during message serialization. enqueue
calls JSON.stringify(entry) which strips functions. After rehydrateMessage, all attachments have fetchData: undefined — handlers cannot
download files/images.
Steps to Reproduce
- Create a Chat instance with
concurrency: { strategy: 'debounce', debounceMs: 2000 }
- Register an
onSubscribedMessage handler that accesses message.attachments[0].fetchData
- Send a message with an image attachment from Slack
- Message enters handleQueueOrDebounce → enqueue → JSON.stringify strips fetchData
- After debounce delay, dequeue → rehydrateMessage → attachments[].fetchData is undefined
- Handler throws: TypeError: fetchData is not a function
Expected Behavior
After dequeue + rehydrate, attachment.fetchData should be a working function. The attachment's url, name, mimeType survive serialization — only
fetchData (a closure) is lost. rehydrateMessage should recreate fetchData from the adapter using att.url.
Actual Behavior
attachment.fetchData is undefined after rehydration. All file/image downloads fail for debounced messages. Works correctly with 'drop' and
'concurrent' strategies (no serialization).
Code Sample
import { Chat } from 'chat';
import { SlackAdapter } from '@chat-adapter/slack';
const chat = new Chat({
adapters: [new SlackAdapter({ botToken: '...' })],
concurrency: { strategy: 'debounce', debounceMs: 2000 },
});
chat.onSubscribedMessage(async (thread, message) => {
const att = message.attachments.find(a => a.type === 'image');
if (att) {
console.log(att.url); // ✅ "https://files.slack.com/..." (survives serialization)
console.log(att.fetchData); // ❌ undefined (closure lost after JSON.stringify)
await att.fetchData(); // 💥 TypeError: fetchData is not a function
}
});
Chat SDK Version
latest
Node.js Version
4.23.0
Platform Adapter
No response
Operating System
None
Additional Context
No response
Bug Description
When using the
debounceorqueueconcurrency strategy,Attachment.fetchDataclosures are lost during message serialization.enqueuecalls
JSON.stringify(entry)which strips functions. AfterrehydrateMessage, all attachments havefetchData: undefined— handlers cannotdownload files/images.
Steps to Reproduce
concurrency: { strategy: 'debounce', debounceMs: 2000 }onSubscribedMessagehandler that accessesmessage.attachments[0].fetchDataExpected Behavior
After dequeue + rehydrate, attachment.fetchData should be a working function. The attachment's url, name, mimeType survive serialization — only
fetchData (a closure) is lost. rehydrateMessage should recreate fetchData from the adapter using att.url.
Actual Behavior
attachment.fetchData is undefined after rehydration. All file/image downloads fail for debounced messages. Works correctly with 'drop' and
'concurrent' strategies (no serialization).
Code Sample
Chat SDK Version
latest
Node.js Version
4.23.0
Platform Adapter
No response
Operating System
None
Additional Context
No response