fix: preserve error cause chains in failure details#310
Open
YunchuWang wants to merge 2 commits into
Open
Conversation
The newFailureDetails() function converts JavaScript errors to protobuf
TaskFailureDetails but never populated the innerFailure field, even when
the source error has a .cause property (ES2022 error chaining).
The protobuf TaskFailureDetails message has a recursive innerFailure
field specifically designed to preserve error chains. The codebase
creates errors with { cause: ... } in 9+ places, but all that inner
diagnostic information was being silently dropped.
This change:
- Recursively populates innerFailure from error.cause
- Adds a depth limit (10) to guard against circular cause chains
- Adds 6 new unit tests covering cause chains, non-Error causes,
depth limits, and the no-cause case
Fixes microsoft#210
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the core protobuf failure-details conversion helper to preserve JavaScript Error.cause chains (recursively) when constructing TaskFailureDetails, aligning behavior with other SDKs and improving debugging fidelity.
Changes:
- Recursively populate protobuf
innerFailurefromError.cause, with a maximum depth cap. - Add Jest coverage for single-level causes, multi-level chains, non-
Errorcauses, and depth limiting.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/durabletask-js/src/utils/pb-helper.util.ts | Populate TaskFailureDetails.innerFailure from Error.cause with a recursion depth limit. |
| packages/durabletask-js/test/pb-helper-versioning.spec.ts | Add tests validating cause-chain preservation and depth limiting behavior. |
…name test - newFailureDetails: guard error.cause with '!= null' instead of truthiness so a falsy-but-present cause (e.g. "" or 0) still populates innerFailure. - Extract recursion into a module-private buildFailureDetails() helper so the public newFailureDetails() signature no longer exposes the internal depth parameter. - Rename the depth-cap test to reflect a deep linear chain (not a cycle). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d175a43f-c852-49a2-a0de-63db579a8e3a
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.
Summary
Fixes #210
Testing
npm test -w @microsoft/durabletask-js -- --runTestsByPath test/pb-helper-versioning.spec.tsnpm run build:core