Skip to content

fix: Serialize custom status eagerly to prevent executor crash on non-serializable values#195

Open
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-custom-status-serialization-crash
Open

fix: Serialize custom status eagerly to prevent executor crash on non-serializable values#195
YunchuWang wants to merge 1 commit intomainfrom
copilot-finds/bug/fix-custom-status-serialization-crash

Conversation

@YunchuWang
Copy link
Member

Fixes #190

Problem

setCustomStatus() stores the raw object without serialization, and getCustomStatus() calls JSON.stringify() lazily. The problem is that getCustomStatus() is called outside the executor's try-catch block, so if a user passes a non-serializable value (e.g., circular references, BigInt), the orchestration result is completely lost.

Changes

  • Serialize eagerly in setCustomStatus() so serialization errors are thrown inside orchestrator code (within the executor's try-catch)
  • Store the pre-serialized JSON string so getCustomStatus() becomes a trivial getter that cannot throw
  • Ensures the orchestration properly fails with a descriptive error rather than silently losing results

setCustomStatus() now serializes the value immediately via JSON.stringify()
instead of deferring serialization to getCustomStatus(). This ensures that
non-serializable values (circular references, BigInt, etc.) throw inside
the orchestrator's try-catch, properly failing the orchestration instead
of crashing the executor and losing the orchestration result.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 23, 2026 22:53
Copy link
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 addresses an executor-crash bug when users call setCustomStatus() with values that JSON.stringify() cannot serialize (e.g., circular references or BigInt). By serializing eagerly inside orchestrator execution, the executor can reliably capture the failure and return completion actions instead of losing the orchestration result.

Changes:

  • Eagerly JSON.stringify() custom status in RuntimeOrchestrationContext.setCustomStatus() and store the pre-serialized JSON string.
  • Make getCustomStatus() a trivial, non-throwing getter.
  • Add Jest coverage for circular references, BigInt, null-clearing behavior, and “no lost result” regression.

Reviewed changes

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

File Description
packages/durabletask-js/src/worker/runtime-orchestration-context.ts Eager custom-status serialization + safer retrieval to prevent executor crashes outside try/catch.
packages/durabletask-js/test/orchestration_context_methods.spec.ts Adds regression tests ensuring non-serializable custom status fails the orchestration without crashing the executor.

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.

[copilot-finds] Bug: setCustomStatus with non-serializable value crashes executor and loses orchestration result

2 participants