Skip to content

Add documentation for custom class serialization#810

Merged
TooTallNate merged 8 commits intomainfrom
01-19-add_documentation_for_custom_class_serialization
Mar 18, 2026
Merged

Add documentation for custom class serialization#810
TooTallNate merged 8 commits intomainfrom
01-19-add_documentation_for_custom_class_serialization

Conversation

@TooTallNate
Copy link
Copy Markdown
Member

@TooTallNate TooTallNate commented Jan 19, 2026

Added documentation for custom class serialization in workflows with new @workflow/serde package.

What changed?

  • Added documentation for the new @workflow/serde package that provides serialization symbols for custom class serialization
  • Added a new section to the serialization docs explaining how to make custom classes serializable
  • Added the @workflow/serde package to the API reference navigation
  • Updated the docs-typecheck extractor to support MDX comments for expect-error annotations

Why make this change?

Custom class serialization is an important feature for workflows that need to work with complex data structures. This documentation explains how developers can make their own classes serializable using the WORKFLOW_SERIALIZE and WORKFLOW_DESERIALIZE symbols from the new @workflow/serde package, enabling seamless passing of class instances between workflow and step functions.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 19, 2026

🦋 Changeset detected

Latest commit: 9830710

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 19, 2026

🧪 E2E Test Results

Some tests failed

Summary

Passed Failed Skipped Total
✅ ▲ Vercel Production 758 0 67 825
✅ 💻 Local Development 782 0 118 900
✅ 📦 Local Production 782 0 118 900
✅ 🐘 Local Postgres 782 0 118 900
✅ 🪟 Windows 72 0 3 75
❌ 🌍 Community Worlds 118 56 15 189
✅ 📋 Other 198 0 27 225
Total 3492 56 466 4014

❌ Failed Tests

🌍 Community Worlds (56 failed)

mongodb (3 failed):

  • hookWorkflow is not resumable via public webhook endpoint
  • webhookWorkflow
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously

redis (2 failed):

  • hookWorkflow is not resumable via public webhook endpoint
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously

turso (51 failed):

  • addTenWorkflow
  • addTenWorkflow
  • wellKnownAgentWorkflow (.well-known/agent)
  • should work with react rendering in step
  • promiseAllWorkflow
  • promiseRaceWorkflow
  • promiseAnyWorkflow
  • importedStepOnlyWorkflow
  • hookWorkflow
  • hookWorkflow is not resumable via public webhook endpoint
  • webhookWorkflow
  • sleepingWorkflow
  • parallelSleepWorkflow
  • nullByteWorkflow
  • workflowAndStepMetadataWorkflow
  • fetchWorkflow
  • promiseRaceStressTestWorkflow
  • error handling error propagation workflow errors nested function calls preserve message and stack trace
  • error handling error propagation workflow errors cross-file imports preserve message and stack trace
  • error handling error propagation step errors basic step error preserves message and stack trace
  • error handling error propagation step errors cross-file step error preserves message and function names in stack
  • error handling retry behavior regular Error retries until success
  • error handling retry behavior FatalError fails immediately without retries
  • error handling retry behavior RetryableError respects custom retryAfter delay
  • error handling retry behavior maxRetries=0 disables retries
  • error handling catchability FatalError can be caught and detected with FatalError.is()
  • hookCleanupTestWorkflow - hook token reuse after workflow completion
  • concurrent hook token conflict - two workflows cannot use the same hook token simultaneously
  • hookDisposeTestWorkflow - hook token reuse after explicit disposal while workflow still running
  • stepFunctionPassingWorkflow - step function references can be passed as arguments (without closure vars)
  • stepFunctionWithClosureWorkflow - step function with closure variables passed as argument
  • closureVariableWorkflow - nested step functions with closure variables
  • spawnWorkflowFromStepWorkflow - spawning a child workflow using start() inside a step
  • health check (queue-based) - workflow and step endpoints respond to health check messages
  • pathsAliasWorkflow - TypeScript path aliases resolve correctly
  • Calculator.calculate - static workflow method using static step methods from another class
  • AllInOneService.processNumber - static workflow method using sibling static step methods
  • ChainableService.processWithThis - static step methods using this to reference the class
  • thisSerializationWorkflow - step function invoked with .call() and .apply()
  • customSerializationWorkflow - custom class serialization with WORKFLOW_SERIALIZE/WORKFLOW_DESERIALIZE
  • instanceMethodStepWorkflow - instance methods with "use step" directive
  • crossContextSerdeWorkflow - classes defined in step code are deserializable in workflow context
  • stepFunctionAsStartArgWorkflow - step function reference passed as start() argument
  • cancelRun - cancelling a running workflow
  • cancelRun via CLI - cancelling a running workflow
  • pages router addTenWorkflow via pages router
  • pages router promiseAllWorkflow via pages router
  • pages router sleepingWorkflow via pages router
  • hookWithSleepWorkflow - hook payloads delivered correctly with concurrent sleep
  • sleepInLoopWorkflow - sleep inside loop with steps actually delays each iteration
  • sleepWithSequentialStepsWorkflow - sequential steps work with concurrent sleep (control)

Details by Category

✅ ▲ Vercel Production
App Passed Failed Skipped
✅ astro 68 0 7
✅ example 68 0 7
✅ express 68 0 7
✅ fastify 68 0 7
✅ hono 68 0 7
✅ nextjs-turbopack 73 0 2
✅ nextjs-webpack 73 0 2
✅ nitro 68 0 7
✅ nuxt 68 0 7
✅ sveltekit 68 0 7
✅ vite 68 0 7
✅ 💻 Local Development
App Passed Failed Skipped
✅ astro-stable 66 0 9
✅ express-stable 66 0 9
✅ fastify-stable 66 0 9
✅ hono-stable 66 0 9
✅ nextjs-turbopack-canary 55 0 20
✅ nextjs-turbopack-stable 72 0 3
✅ nextjs-webpack-canary 55 0 20
✅ nextjs-webpack-stable 72 0 3
✅ nitro-stable 66 0 9
✅ nuxt-stable 66 0 9
✅ sveltekit-stable 66 0 9
✅ vite-stable 66 0 9
✅ 📦 Local Production
App Passed Failed Skipped
✅ astro-stable 66 0 9
✅ express-stable 66 0 9
✅ fastify-stable 66 0 9
✅ hono-stable 66 0 9
✅ nextjs-turbopack-canary 55 0 20
✅ nextjs-turbopack-stable 72 0 3
✅ nextjs-webpack-canary 55 0 20
✅ nextjs-webpack-stable 72 0 3
✅ nitro-stable 66 0 9
✅ nuxt-stable 66 0 9
✅ sveltekit-stable 66 0 9
✅ vite-stable 66 0 9
✅ 🐘 Local Postgres
App Passed Failed Skipped
✅ astro-stable 66 0 9
✅ express-stable 66 0 9
✅ fastify-stable 66 0 9
✅ hono-stable 66 0 9
✅ nextjs-turbopack-canary 55 0 20
✅ nextjs-turbopack-stable 72 0 3
✅ nextjs-webpack-canary 55 0 20
✅ nextjs-webpack-stable 72 0 3
✅ nitro-stable 66 0 9
✅ nuxt-stable 66 0 9
✅ sveltekit-stable 66 0 9
✅ vite-stable 66 0 9
✅ 🪟 Windows
App Passed Failed Skipped
✅ nextjs-turbopack 72 0 3
❌ 🌍 Community Worlds
App Passed Failed Skipped
✅ mongodb-dev 3 0 2
❌ mongodb 52 3 3
✅ redis-dev 3 0 2
❌ redis 53 2 3
✅ turso-dev 3 0 2
❌ turso 4 51 3
✅ 📋 Other
App Passed Failed Skipped
✅ e2e-local-dev-nest-stable 66 0 9
✅ e2e-local-postgres-nest-stable 66 0 9
✅ e2e-local-prod-nest-stable 66 0 9

📋 View full workflow run

Copy link
Copy Markdown
Member Author

TooTallNate commented Jan 19, 2026

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jan 19, 2026

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

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
example-workflow Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workbench-astro-workflow Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workbench-express-workflow Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workbench-fastify-workflow Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workbench-hono-workflow Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workbench-nitro-workflow Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workbench-nuxt-workflow Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workbench-sveltekit-workflow Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workbench-vite-workflow Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workflow-docs Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workflow-nest Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm
workflow-swc-playground Ready Ready Preview, Comment, Open in v0 Mar 17, 2026 11:53pm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive documentation for the custom class serialization feature using the new @workflow/serde package. The documentation explains how developers can make their custom classes serializable in workflows by implementing WORKFLOW_SERIALIZE and WORKFLOW_DESERIALIZE symbols.

Changes:

  • Added a new "Custom Class Serialization" section to the serialization documentation with examples showing basic and complex usage patterns
  • Updated the docs-typecheck extractor to support MDX-style comments for @expect-error annotations in addition to HTML comments
  • Added the @workflow/serde package to the API reference navigation and index

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/docs-typecheck/src/extractor.ts Enhanced regex to support both HTML and MDX comment formats for @expect-error annotations
docs/content/docs/foundations/serialization.mdx Added comprehensive documentation section explaining custom class serialization with code examples
docs/content/docs/api-reference/meta.json Added workflow-serde to the API reference pages list
docs/content/docs/api-reference/index.mdx Added Card component linking to the @workflow/serde package documentation
.changeset/smooth-nails-do.md Empty changeset file (acceptable for documentation-only changes)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…tance methods

- Add custom classes to Supported Serializable Types with anchor link
- Replace verbose parenthetical in Requirements with back-link
- Add [!code highlight] to Basic Example serde methods
- Simplify geometry.ts to import Point instead of redefining it
- Rewrite Complex Example to demonstrate 'use step' on instance methods
  with realistic APIs (database, HTTP) and contrast with workflow-context methods
- Add pass-by-value note for 'this' context with return-and-reassign pattern
Add @skip-typecheck to bare static method signatures that aren't valid
standalone TypeScript.
const CODE_BLOCK_REGEX =
/```(typescript|ts|javascript|js)(?:[^\S\n]+[^\n]*)?\n([\s\S]*?)```/g;
const EXPECT_ERROR_REGEX = /<!--\s*@expect-error:([0-9,\s]+)\s*-->/;
// Support both HTML comments (<!-- @expect-error:2351 -->) and MDX comments ({/* @expect-error:2351 */})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what is this change for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The @expect-error marker only supported HTML comment syntax (<!-- @expect-error:2351 -->), which was sufficient since the only prior usage was in a .md file (the docs-typecheck README). However, MDX files do not support HTML comments — the MDX parser rejects <!-- with "Unexpected character !". Since the serialization docs are .mdx files and need @expect-error markers, this adds support for the MDX comment syntax ({/* @expect-error:2351 */}) as an alternative. The @skip-typecheck marker already supported both formats.

The docs typecheck extractor only supports HTML comment syntax for
@expect-error on main. Use <!-- @expect-error:XXXX --> instead of
{/* @expect-error:XXXX */} to match the existing convention.
…extractor

MDX files don't support HTML comments (<!-- -->). The extractor's
@expect-error regex only supported HTML syntax, but @skip-typecheck
already supported both. This aligns @expect-error to also support
the MDX comment syntax ({/* @expect-error:XXXX */}).
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.

3 participants