Skip to content

fix: preserve error name through the serialization pipeline for proper error rehydration#1504

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-stream-pagination-metadata-endpoints
Draft

fix: preserve error name through the serialization pipeline for proper error rehydration#1504
Copilot wants to merge 2 commits intomainfrom
copilot/add-stream-pagination-metadata-endpoints

Conversation

Copy link
Contributor

Copilot AI commented Mar 24, 2026

WorkflowNotRegisteredError and StepNotRegisteredError were introduced in #1452 but the serialization pipeline only stored message/stack — dropping the class name. Rehydrated errors were always plain Error instances, making .is() checks silently fail.

Changes

  • @workflow/world — Added name?: string to StructuredErrorSchema
  • @workflow/core (runtime) — Include name in run_failed event error objects
  • @workflow/core (step-handler) — Store StepNotRegisteredError as { message, name } object in step_failed events (was a plain string)
  • @workflow/core (step) — Extract name from step_failed error object and set it on the rejected FatalError, so .is() checks work inside workflow catch blocks
  • @workflow/errorsWorkflowRunFailedError now sets causeError.name from StructuredError.name, enabling WorkflowNotRegisteredError.is(err.cause)
  • @workflow/world-local, @workflow/world-postgres, @workflow/world-vercel — Preserve name when mapping failure events → StructuredError / JSON serialization round-trips

After this change:

try {
  await myStep();
} catch (e) {
  if (StepNotRegisteredError.is(e)) {
    // now reachable — e.name === 'StepNotRegisteredError'
  }
}

// and for run-level errors:
if (WorkflowRunFailedError.is(err)) {
  WorkflowNotRegisteredError.is(err.cause); // true
}

How did you test your changes?

  • Updated step-handler.test.ts assertions to match the new structured error object format for StepNotRegisteredError events
  • Added a unit test in step.test.ts verifying that error.name is preserved from step_failed event data
  • All 494 unit tests pass across @workflow/core, @workflow/world-local, and @workflow/world-vercel

PR Checklist - Required to merge

  • 📦 pnpm changeset was run to create a changelog for this PR
    • During beta, we only use "patch" mode for changes. Don't tag minor/major versions.
    • Use pnpm changeset --empty if you are changing documentation or workbench apps
  • 🔒 DCO sign-off passes (run git commit --signoff on your commits)
  • 📝 Ping @vercel/workflow in a comment once the PR is ready, and the above checklist is complete

View original Slack conversation


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

@changeset-bot
Copy link

changeset-bot bot commented Mar 24, 2026

🦋 Changeset detected

Latest commit: a784114

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

This PR includes changesets to release 21 packages
Name Type
@workflow/core Patch
@workflow/errors Patch
@workflow/world Patch
@workflow/world-local Patch
@workflow/world-vercel Patch
@workflow/world-postgres Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/vitest Patch
@workflow/web-shared Patch
workflow Patch
@workflow/world-testing Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
@workflow/nuxt Patch
@workflow/ai Patch

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

@vercel
Copy link
Contributor

vercel bot commented Mar 24, 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 Mar 24, 2026 5:25pm
example-nextjs-workflow-webpack Ready Ready Preview, Comment Mar 24, 2026 5:25pm
example-workflow Ready Ready Preview, Comment Mar 24, 2026 5:25pm
workbench-astro-workflow Ready Ready Preview, Comment Mar 24, 2026 5:25pm
workbench-express-workflow Ready Ready Preview, Comment Mar 24, 2026 5:25pm
workbench-fastify-workflow Ready Ready Preview, Comment Mar 24, 2026 5:25pm
workbench-hono-workflow Ready Ready Preview, Comment Mar 24, 2026 5:25pm
workbench-nitro-workflow Ready Ready Preview, Comment Mar 24, 2026 5:25pm
workbench-nuxt-workflow Ready Ready Preview, Comment Mar 24, 2026 5:25pm
workbench-sveltekit-workflow Ready Ready Preview, Comment Mar 24, 2026 5:25pm
workbench-vite-workflow Ready Ready Preview, Comment Mar 24, 2026 5:25pm
workflow-docs Ready Ready Preview, Comment, Open in v0 Mar 24, 2026 5:25pm
workflow-swc-playground Ready Ready Preview, Comment Mar 24, 2026 5:25pm

Copilot AI changed the title [WIP] Add stream pagination and metadata endpoints fix: preserve error name through the serialization pipeline for proper error rehydration Mar 24, 2026
Copilot AI requested a review from pranaygp March 24, 2026 17:29
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.

2 participants