Skip to content

fix(chat): export standalone reviver for workflow-safe deserialization#257

Open
haydenbleasel wants to merge 1 commit intomainfrom
243-durable-chat-sessions-guide-fails-with-workflow-node-module-error
Open

fix(chat): export standalone reviver for workflow-safe deserialization#257
haydenbleasel wants to merge 1 commit intomainfrom
243-durable-chat-sessions-guide-fails-with-workflow-node-module-error

Conversation

@haydenbleasel
Copy link
Contributor

Summary

  • Adds a standalone reviver function exported from chat that deserializes Thread/Channel/Message objects without requiring a Chat instance (and its adapter Node.js dependencies)
  • Updates Chat.reviver() to delegate to the standalone function internally
  • Updates the durable chat sessions guide to use reviver from chat and dynamically import bot inside "use step" functions

Closes #243

Test plan

  • pnpm validate passes (knip, lint, typecheck, tests, build)
  • New tests for standalone reviver in serialization.test.ts
  • Verify the updated guide pattern works with a real Vercel Workflow project

Importing the Chat instance into Vercel Workflow files pulls in adapter
packages that depend on Node.js modules, which aren't available in the
workflow sandbox. This adds a standalone `reviver` function exported from
`chat` that deserializes Thread/Channel/Message objects without needing
a Chat instance or its adapter dependencies.

Also updates the durable chat sessions guide to use the standalone
reviver and dynamic bot imports inside step functions.

Closes #243

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Mar 16, 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 Mar 16, 2026 8:10pm
chat-sdk-nextjs-chat Ready Ready Preview, Comment, Open in v0 Mar 16, 2026 8:10pm

Copy link
Contributor

@bensabic bensabic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working through the Workflow sandbox issue, @haydenbleasel! The standalone reviver direction makes sense, but I don’t think this is quite ready to merge yet.

I found two follow-ups that still need to be addressed:

  1. ChannelImpl has the same lazy round-trip bug as ThreadImpl. A chat:Channel revived via the new standalone reviver still can’t be serialized again without a registered singleton, because toJSON() derives adapterName from this.adapter.name instead of preserving the stored adapter name. This makes the new helper incomplete for channel payloads too.

  2. The docs are now internally inconsistent around the new API. The durable session guide points readers to the Chat API for reviver, but apps/docs/content/docs/api/chat.mdx still only documents bot.reviver(), not the new root export.

If you fix the lazy serialization path by preserving adapterName on round-trip and update the API docs to cover the new export, this should be in a better shape.

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.

Durable chat sessions guide fails with workflow-node-module-error

2 participants