From ee1d18e07cdeb4338a2828eb22d51b9871c9b13a Mon Sep 17 00:00:00 2001 From: lihan3238 Date: Fri, 8 May 2026 12:02:12 +0800 Subject: [PATCH 1/2] fix(Cause): align toJSON key with actual property name The Fail case in Cause.toJSON used the key "failure" but the actual property name is "error". All other variants (Die, Interrupt, Sequential, Parallel) already use keys matching their property names. This makes toJSON output consistent with the runtime object shape. Closes #4683 --- packages/effect/src/internal/cause.ts | 2 +- packages/effect/test/Cause.test.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/effect/src/internal/cause.ts b/packages/effect/src/internal/cause.ts index e557a914235..cfdf8a999f4 100644 --- a/packages/effect/src/internal/cause.ts +++ b/packages/effect/src/internal/cause.ts @@ -60,7 +60,7 @@ const proto = { case "Interrupt": return { _id: "Cause", _tag: this._tag, fiberId: this.fiberId.toJSON() } case "Fail": - return { _id: "Cause", _tag: this._tag, failure: toJSON(this.error) } + return { _id: "Cause", _tag: this._tag, error: toJSON(this.error) } case "Sequential": case "Parallel": return { _id: "Cause", _tag: this._tag, left: toJSON(this.left), right: toJSON(this.right) } diff --git a/packages/effect/test/Cause.test.ts b/packages/effect/test/Cause.test.ts index 0220598384a..a409909442d 100644 --- a/packages/effect/test/Cause.test.ts +++ b/packages/effect/test/Cause.test.ts @@ -123,7 +123,7 @@ describe("Cause", () => { expectJSON(Cause.fail(Option.some(1)), { _id: "Cause", _tag: "Fail", - failure: { + error: { _id: "Option", _tag: "Some", value: 1 @@ -189,12 +189,12 @@ describe("Cause", () => { left: { _id: "Cause", _tag: "Fail", - failure: "failure 1" + error: "failure 1" }, right: { _id: "Cause", _tag: "Fail", - failure: "failure 2" + error: "failure 2" } }) }) @@ -206,12 +206,12 @@ describe("Cause", () => { left: { _id: "Cause", _tag: "Fail", - failure: "failure 1" + error: "failure 1" }, right: { _id: "Cause", _tag: "Fail", - failure: "failure 2" + error: "failure 2" } }) }) From 8771e8e684ad98faaaa73457cfed75f6f5c66079 Mon Sep 17 00:00:00 2001 From: lihan3238 Date: Fri, 8 May 2026 12:11:25 +0800 Subject: [PATCH 2/2] add changeset --- .changeset/fix-cause-tojson-key.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-cause-tojson-key.md diff --git a/.changeset/fix-cause-tojson-key.md b/.changeset/fix-cause-tojson-key.md new file mode 100644 index 00000000000..b86813affda --- /dev/null +++ b/.changeset/fix-cause-tojson-key.md @@ -0,0 +1,5 @@ +--- +"effect": patch +--- + +fix(Cause): align toJSON key with actual property name