fix: Align TestOrchestrationClient null serialization with TaskHubGrpcClient#199
Open
YunchuWang wants to merge 1 commit intomainfrom
Open
fix: Align TestOrchestrationClient null serialization with TaskHubGrpcClient#199YunchuWang wants to merge 1 commit intomainfrom
YunchuWang wants to merge 1 commit intomainfrom
Conversation
…ivergence from real client TestOrchestrationClient.raiseOrchestrationEvent and terminateOrchestration handle null values differently from the real TaskHubGrpcClient, causing behavioral divergence between test and production environments. Real client (TaskHubGrpcClient): Always calls JSON.stringify(data), which turns null into the string "null". The sidecar stores this, and the orchestrator receives null when deserializing. Test client (TestOrchestrationClient): Skipped serialization for null with 'data !== null ? JSON.stringify(data) : undefined', which caused the orchestrator to receive undefined instead of null. This fix aligns the test client with the real client by unconditionally serializing the data, so orchestrations tested with the in-memory backend receive the same values they would in production. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns the in-memory TestOrchestrationClient serialization semantics with the production TaskHubGrpcClient, eliminating a test-vs-prod behavioral mismatch for null event payloads and termination output.
Changes:
- Update
TestOrchestrationClient.raiseOrchestrationEvent()to alwaysJSON.stringify(data)(includingnull). - Update
TestOrchestrationClient.terminateOrchestration()to alwaysJSON.stringify(output)(includingnull). - Add Jest regression tests validating
null(and other falsy) payload round-tripping behavior in the in-memory test stack.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/durabletask-js/src/testing/test-client.ts | Makes event/termination payload encoding match production behavior by always stringifying null. |
| packages/durabletask-js/test/test-client-serialization.spec.ts | Adds coverage to ensure null (and other falsy values) are delivered/stored consistently in tests. |
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 #186
Problem
TestOrchestrationClient.raiseOrchestrationEvent and terminateOrchestration handle null data differently from the real TaskHubGrpcClient, causing behavioral divergence between test and production environments. The test client skips serialization for null, while the real client always serializes (null becomes the string 'null').
Changes