Skip to content

feat: restore attachment fetchData after queue/debounce serialization#338

Merged
dancer merged 10 commits intomainfrom
josh/fix-fetchdata-serialization
Apr 14, 2026
Merged

feat: restore attachment fetchData after queue/debounce serialization#338
dancer merged 10 commits intomainfrom
josh/fix-fetchdata-serialization

Conversation

@dancer
Copy link
Copy Markdown
Contributor

@dancer dancer commented Apr 6, 2026

summary

attachment fetchData closures are lost when messages pass through queue/debounce concurrency strategies because JSON.stringify strips functions during enqueue. after dequeue and rehydration, handlers get fetchData: undefined and can't download files

adds fetchMetadata field to Attachment for storing platform-specific IDs that survive serialization (e.g. WhatsApp mediaId, Telegram fileId, Google Chat resourceName, Slack teamId), and rehydrateAttachment optional method to Adapter for rebuilding fetchData closures from those IDs after deserialization

slack multi-workspace: stores teamId in fetchMetadata and resolves the token via getInstallation(teamId) at download time - no tokens in serialized data, handles token rotation

implemented in all five adapters that use fetchData: slack, whatsapp, telegram, gchat, teams

closes #323
closes #299

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview, Comment, Open in v0 Apr 14, 2026 4:13am
chat-sdk-nextjs-chat Ready Ready Preview, Comment, Open in v0 Apr 14, 2026 4:13am

dancer and others added 10 commits April 14, 2026 05:07
- Slack createAttachment now calls fetchSlackFile instead of duplicating fetch logic inline
- Remove unnecessary IIFE wrapper in fetchSlackFile
- Fix redundant optional chain in rehydrateMessage by extracting bound method
- Full JSON.stringify/parse roundtrip test for fetchMetadata in message.test.ts
- Queue drain test: rehydrateAttachment called on deserialized attachments
- Queue drain test: skip rehydration when fetchData already present
- Queue drain test: attachments unchanged when adapter has no rehydrateAttachment
@dancer dancer merged commit 1e7c551 into main Apr 14, 2026
12 checks passed
@dancer dancer deleted the josh/fix-fetchdata-serialization branch April 14, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attachment fetchData lost after debounce/queue serialization No attachment fetchData in WhatsApp queued messages

2 participants