Skip to content

Inconsistency between Cause.Fail instance and toJSON #4683

Closed

Description

@Wraul

What version of Effect is running?

3.14.1

What steps can reproduce the bug?

import { Cause } from "effect";

const cause = Cause.fail("Error");

console.log(cause);

if (Cause.isFailType(cause)) {
  // console.log(cause.failure); <-- does not type check
  console.log(cause.error);
}

The console.log(cause) prints the following

{ _id: 'Cause', _tag: 'Fail', failure: 'Error' }

Indicating that there should be a failure property on the cause object. But in reality there is none as can be seen in the if statement. There is a error property though.

What is the expected behavior?

I was expecting that what the console.log emitted should correspond to the structure of the cause object.

What do you see instead?

The console.log(cause) indicates that there is a failure property on the cause object, when there in fact is no such property.

Additional information

I believe this are due to the toJSON implementation for the Cause.Fail in effect/src/internal/cause.ts.

Activity

  1. added
    bug
    on Apr 1, 2025
  2. added
    3.0
    on Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.0bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions