feat: restore attachment fetchData after queue/debounce serialization#338
feat: restore attachment fetchData after queue/debounce serialization#338
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
b836e28 to
9250d36
Compare
9250d36 to
a219a36
Compare
a219a36 to
86b02fc
Compare
| ...attachment, | ||
| fetchData: () => this.fetchSlackFile(url, this.getToken()), | ||
| }; | ||
| } |
There was a problem hiding this comment.
rehydrateAttachment calls this.getToken() lazily at fetch time, but rehydration runs from a queue consumer where there is no AsyncLocalStorage request context. In multi-workspace deployments this will throw AuthenticationError("No bot token available").
The original createAttachment captures the token eagerly during webhook processing for exactly this reason. The new path loses that.
fetchMetadata only stores { url } today, so there is no way to recover which workspace's token to use after deserialization. Either the token needs to be stored in fetchMetadata so it survives the roundtrip, or this needs to be scoped to single-workspace only.
- 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
summary
attachment
fetchDataclosures are lost when messages pass through queue/debounce concurrency strategies becauseJSON.stringifystrips functions during enqueue. after dequeue and rehydration, handlers getfetchData: undefinedand can't download filesadds
fetchMetadatafield toAttachmentfor storing platform-specific IDs that survive serialization (e.g. WhatsAppmediaId, TelegramfileId, Google ChatresourceName), andrehydrateAttachmentoptional method toAdapterfor rebuildingfetchDataclosures from those IDs after deserializationimplemented in all five adapters that use
fetchData: slack, whatsapp, telegram, gchat, teamscloses #323
closes #299