Skip to content

Preserve mixed failures and interruptions in catchDefect - #9387

Closed
effect-bot wants to merge 2 commits into
mainfrom
agent/effect-bot/d2ef74ed79c1
Closed

effect-bot wants to merge 2 commits into
mainfrom
agent/effect-bot/d2ef74ed79c1

Conversation

@effect-bot

Copy link
Copy Markdown
Contributor

Summary

  • Recover only causes consisting entirely of defects in Effect.catchDefect and Channel.catchDefect (and Stream via Channel).
  • Preserve the original mixed cause, including typed failures and interruptions, without changing public Cause.findDefect semantics.
  • Include the tests-only handoff unchanged and a patch changeset.

Validation

  • Before the fix: 6 mixed-cause regressions failed; 3 pure-defect recovery tests passed.
  • After the fix: all 9 focused catchDefect tests pass; all 744 tests across Effect.test.ts, Stream.test.ts, and Channel.test.ts pass.
  • nix develop -c pnpm lint-fix and nix develop -c pnpm check pass.
  • Tests unchanged from handoff commit 07e8d9c.

Closes #9368
Closes EFF-2341

@changeset-bot

changeset-bot Bot commented Oct 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 064e878

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-janitor effect-janitor Bot added the 4.0 label Oct 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 38.99 KB 38.99 KB 0.00 KB (0.00%)
basic.ts 7.02 KB 7.02 KB 0.00 KB (0.00%)
batching.ts 10.73 KB 10.73 KB 0.00 KB (0.00%)
brand.ts 6.71 KB 6.71 KB 0.00 KB (0.00%)
cache.ts 11.26 KB 11.26 KB 0.00 KB (0.00%)
config.ts 22.41 KB 22.41 KB 0.00 KB (0.00%)
differ.ts 21.52 KB 21.52 KB 0.00 KB (0.00%)
http-client.ts 23.93 KB 23.93 KB 0.00 KB (0.00%)
http-router.ts 35.48 KB 35.48 KB 0.00 KB (0.00%)
logger.ts 11.60 KB 11.60 KB 0.00 KB (0.00%)
metric.ts 9.08 KB 9.08 KB 0.00 KB (0.00%)
optic.ts 6.93 KB 6.93 KB 0.00 KB (0.00%)
pubsub.ts 15.68 KB 15.68 KB 0.00 KB (0.00%)
queue.ts 12.52 KB 12.52 KB 0.00 KB (0.00%)
schedule.ts 11.73 KB 11.73 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.76 KB 13.76 KB 0.00 KB (0.00%)
schema-binary.ts 40.46 KB 40.46 KB 0.00 KB (0.00%)
schema-class.ts 21.20 KB 21.20 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 32.24 KB 32.24 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.41 KB 27.41 KB 0.00 KB (0.00%)
schema-string-transformation.ts 14.93 KB 14.93 KB 0.00 KB (0.00%)
schema-string.ts 12.02 KB 12.02 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.19 KB 16.19 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.51 KB 38.51 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 25.53 KB 25.53 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.45 KB 20.45 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.65 KB 20.65 KB 0.00 KB (0.00%)
schema-toFormatter.ts 20.75 KB 20.75 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 25.38 KB 25.38 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 20.74 KB 20.74 KB 0.00 KB (0.00%)
schema.ts 20.39 KB 20.39 KB 0.00 KB (0.00%)
stm.ts 13.79 KB 13.79 KB 0.00 KB (0.00%)
stream.ts 10.05 KB 10.05 KB 0.00 KB (0.00%)

@effect-bot

Copy link
Copy Markdown
Contributor Author

Closing without merging. In mixed causes defects take precedence, so catchDefect recovering Fail + Die and Interrupt + Die is the intended behavior. This matches Effect 3's catchAllDefect. With this change applied, Effect.catch would still recover Fail + Die and drop the defect, which inverts the precedence. More detail and links to the v3 implementation are in #9368.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Effect.catchDefect discards a typed failure or interruption that sits beside the defect (e.g. a finalizer that dies)

1 participant