fix: Serialize custom status eagerly to prevent executor crash on non-serializable values#195
Open
YunchuWang wants to merge 1 commit intomainfrom
Open
Conversation
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>
Contributor
There was a problem hiding this comment.
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 inRuntimeOrchestrationContext.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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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