Skip to content

fix: preserve workflow defect details in test diagnostics - #5

Open
sundaray wants to merge 1 commit into
TeamSpringbird:mainfrom
sundaray:fix/decode-workflow-result-error-formatting
Open

fix: preserve workflow defect details in test diagnostics#5
sundaray wants to merge 1 commit into
TeamSpringbird:mainfrom
sundaray:fix/decode-workflow-result-error-formatting

Conversation

@sundaray

Copy link
Copy Markdown

Summary

  • Updated decodeWorkflowResult in src/testing.ts to render failed workflow results with Cause.pretty instead of JSON.stringify.
  • Added a regression test in src/__tests__/testing.test.ts for native Error defects round-tripped through the workflow wire codec.

Problem

In src/testing.ts, decodeWorkflowResult currently formats a failed Effect Cause using:

JSON.stringify(exit.cause)

The regression test reproduces the problem by encoding a workflow defect containing a native error:

Exit.die(new Error("boom"))

Native Error properties such as message and stack are non-enumerable, so JSON.stringify omits them. The resulting diagnostic is:

workflow "effectDemo" did not succeed: {"_id":"Cause","failures":[{"_tag":"Die","defect":{}}]}

Notice that defect is rendered as {} even though the original error's message was "boom".

Using Effect's Cause.pretty renderer preserves that message:

workflow "effectDemo" did not succeed: Error: boom

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.

1 participant