Skip to content

Add SerializationContext API for core payload/failure conversion paths#1996

Open
THardy98 wants to merge 8 commits intomainfrom
feat/ts-serialization-context-core
Open

Add SerializationContext API for core payload/failure conversion paths#1996
THardy98 wants to merge 8 commits intomainfrom
feat/ts-serialization-context-core

Conversation

@THardy98
Copy link
Copy Markdown
Contributor

@THardy98 THardy98 commented Apr 6, 2026

What was changed

Added SerializationContext API for core payload/failure conversion paths (i.e. workflows and activities).

Scope of this PR is limited to core workflow/activity boundaries (as an effort to split: #1950 into easier to review chunks).

Specifically, the boundaries implemented in this PR are:

Boundary Payload Context Failure Context
Workflow start args Workflow N/A
Workflow result Workflow N/A
Workflow failure N/A Workflow
Query args/result Workflow N/A
Update args/result Workflow N/A
Signal receive payload Workflow N/A
Remote activity args/result Activity Activity
Remote activity failure observed by workflow N/A Activity
Remote activity heartbeat details Activity N/A
Local activity args/result Activity (isLocal=true) Activity (isLocal=true)
Local activity failure observed by workflow N/A Activity (isLocal=true)
Child workflow start args/result Child workflow Child workflow
Child workflow failure observed by parent N/A Child workflow
External workflow signal payload (success) Target workflow Target workflow
External workflow signal failure N/A Target workflow
External workflow cancel failure N/A Target workflow
Continue-as-new args Workflow N/A
Workflow memo upsert encode path Workflow N/A
Timer summary encode path Workflow N/A
Activity pre-start heartbeat-details decode failure N/A Activity

Note for reviewers:
The diff looks big but about half of it is the test suite at test-serialization-context.ts. It might be easier to review this PR starting there, to see what the serialization context across these boundaries look like.


  1. Part of [[Feature Request] Serialization context for codecs and converters #1661]

  2. How was this tested:

  • Comprehensive test suite at test-serialization-context.ts for the boundaries implemented
  • Also a test in test-worker-heartbeating.ts to check serialization context is correct when activity start task fails (specifically when it fails during extractActivityInfo for a failed activity heartbeat, we want to check that the serialization context is propagated through the failure correctly).

THardy98 added 3 commits April 5, 2026 19:17
Wire serialization context through the core workflow, worker, and
primary client paths so custom payload and failure converters can
see which workflow or activity owns each payload. Add focused tests
for the main success and failure boundaries.

See tests in test-serialization-context.ts and the workflows it
uses in test/src/workflows/serialization-context.ts to see the
current boundaries where serialization context is implemented.
@THardy98 THardy98 force-pushed the feat/ts-serialization-context-core branch from 8377564 to 234615e Compare April 6, 2026 02:17
@THardy98 THardy98 force-pushed the feat/ts-serialization-context-core branch from 72d109a to ab2bd73 Compare April 6, 2026 03:16
@THardy98 THardy98 marked this pull request as ready for review April 6, 2026 16:12
@THardy98 THardy98 requested a review from a team as a code owner April 6, 2026 16:12
Copy link
Copy Markdown
Contributor

@mjameswh mjameswh left a comment

Choose a reason for hiding this comment

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

At workflow-client.ts:1615 (new code), we pass the unbound data converter to executionInfoFromRaw so that we can later decode a workflow's memo, which is correct.

But then, I'd expect executionInfoFromRaw to bind workflow id when actually calling the data converter.

import type { PayloadConverter } from './payload-converter';

/**
* Context for payloads owned by a workflow.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Context for payloads owned by a workflow.
* Context provided to data converters for payloads owned by a workflow.

const activator = getActivator();
validateActivityOptions(options);
const activityId = options.activityId ?? `${seq}`;
const context = activitySerializationContext(activator.info, activityId, false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the use case for "activity id" in the activity serialization context?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

standalone activities

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see. But in the case of activities scheduled from a workflow, I'm not sure passing seq as activity id is desirable. I don't see how users could possibly do good use of that information, yet they will like be some that will misuse it (e.g. by assuming that "activity id" would be globally unique, which seq won't be.

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