Skip to content

Retain an Effect atom's exposed success after asynchronous failure - #9607

Merged
tim-smart merged 3 commits into
mainfrom
agent/nelson-effect-bot/27480f5f818c
Oct 20, 2026
Merged

tim-smart merged 3 commits into
mainfrom
agent/nelson-effect-bot/27480f5f818c

Conversation

@effect-bot

Copy link
Copy Markdown
Contributor

An Effect atom with initialValue exposes that value as a waiting Success while its first asynchronous run is in flight. When that run failed, makeEffect built the failure from the ctx.self() snapshot taken before the run started, which is None on first mount, so previousSuccess was dropped. Stream atoms already read ctx.self() at failure time and kept it.

Asynchronous completion now builds the result from the atom's current value, so the failure keeps the latest success that was actually exposed: the initial value, or a success published with get.setSelf. This applies to direct, function-form, and runtime.atom Effect atoms. Synchronous completion still uses the pre-run snapshot, so a synchronous failure keeps no previous success when the initial value was never exposed.

Interruption is unchanged. Rebuilding or disposing the atom removes the fiber observer before interrupting, including for uninterruptible atoms, so a stale run cannot write over the newer value. If the effect interrupts itself asynchronously, it now keeps the exposed success like any other asynchronous failure.

Regression tests are in packages/effect/test/reactivity/Atom.test.ts (added in the first commit).

Closes #9605
Closes EFF-2573

@changeset-bot

changeset-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 844dde6

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

@tim-smart
tim-smart enabled auto-merge (squash) October 20, 2026 08:40
@tim-smart
tim-smart merged commit 30319d5 into main Oct 20, 2026
12 checks passed
@tim-smart
tim-smart deleted the agent/nelson-effect-bot/27480f5f818c branch October 20, 2026 08:42
@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 39.11 KB 39.11 KB 0.00 KB (0.00%)
basic.ts 7.02 KB 7.02 KB 0.00 KB (0.00%)
batching.ts 10.89 KB 10.89 KB 0.00 KB (0.00%)
brand.ts 6.71 KB 6.71 KB 0.00 KB (0.00%)
cache.ts 11.33 KB 11.33 KB 0.00 KB (0.00%)
config.ts 22.57 KB 22.57 KB 0.00 KB (0.00%)
differ.ts 21.63 KB 21.63 KB 0.00 KB (0.00%)
http-client.ts 24.10 KB 24.10 KB 0.00 KB (0.00%)
http-router.ts 35.66 KB 35.66 KB 0.00 KB (0.00%)
logger.ts 11.68 KB 11.68 KB 0.00 KB (0.00%)
metric.ts 9.26 KB 9.26 KB 0.00 KB (0.00%)
optic.ts 6.93 KB 6.93 KB 0.00 KB (0.00%)
pubsub.ts 15.77 KB 15.77 KB 0.00 KB (0.00%)
queue.ts 12.59 KB 12.59 KB 0.00 KB (0.00%)
schedule.ts 11.77 KB 11.77 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.82 KB 13.82 KB 0.00 KB (0.00%)
schema-binary.ts 40.51 KB 40.51 KB 0.00 KB (0.00%)
schema-class.ts 21.34 KB 21.34 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 32.30 KB 32.30 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.50 KB 27.50 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.07 KB 15.07 KB 0.00 KB (0.00%)
schema-string.ts 12.08 KB 12.08 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.00 KB 16.00 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.63 KB 38.63 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 25.69 KB 25.69 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.57 KB 20.57 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.75 KB 20.75 KB 0.00 KB (0.00%)
schema-toFormatter.ts 20.86 KB 20.86 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 25.50 KB 25.50 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 20.85 KB 20.85 KB 0.00 KB (0.00%)
schema.ts 20.53 KB 20.53 KB 0.00 KB (0.00%)
stm.ts 13.87 KB 13.87 KB 0.00 KB (0.00%)
stream.ts 10.12 KB 10.12 KB 0.00 KB (0.00%)

brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Oct 25, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `@effect/platform-node` | 4.0.5 | 4.0.6 | patch |
| `@tanstack/react-router` | 1.170.45 | 1.170.46 | patch |
| `@tanstack/react-start` | 1.169.3 | 1.169.4 | patch |
| `ai` | 7.0.148 | 7.0.149 | patch |
| `effect` | 4.0.5 | 4.0.6 | patch |
| `effectful-better-auth` | 1.0.7 | 1.0.8 | patch |

## Release Notes

<details>
<summary><b>@<!---->effect/platform-node</b> (4.0.5 → 4.0.6)</summary>

### Patch Changes

- [#9506](Effect-TS/effect#9506)
[`679f956`](Effect-TS/effect@679f956)
Thanks @<!---->tim-smart! - Use `Effect.fnUntraced` for internal
functions that returned `Effect.gen`.

- [#9262](Effect-TS/effect#9262)
[`51930c0`](Effect-TS/effect@51930c0)
Thanks @<!---->effect-bot! - Return a typed multipart parse error
instead of a defect when a multipart request is missing its boundary.

- [#9402](Effect-TS/effect#9402)
[`d1201f0`](Effect-TS/effect@d1201f0)
Thanks @<!---->effect-bot! - Release writables created by
`NodeSink.fromWritable` and `fromWritableChannel` when upstream fails or
the sink is interrupted, preserving the original exit cause. Writables
using `endOnDone: false` remain open. Preserve stream body encoding
errors in the Node HTTP client instead of reporting transport errors
caused by request cleanup.

- [#9575](Effect-TS/effect#9575)
[`c29ddd8`](Effect-TS/effect@c29ddd8)
Thanks @<!---->tim-smart! - Add streaming request payloads to `HttpApi`.
An endpoint can declare `HttpApiSchema.StreamUint8Array` or the new
`HttpApiSchema.StreamNdjson({ schema })` as its `payload`, and the
handler receives a lazy `Stream` that reads the body as it pulls. Bad
NDJSON lines fail the stream with `HttpApiSchemaError` (400). The new
`maxBytes` and `maxElementBytes` limits fail it with the new
`HttpApiPayloadTooLarge` (413), and a `content-length` over `maxBytes`
is rejected before the handler runs. `StreamNdjson` also works as a
success response.
  
`HttpApiClient` sends a `Stream` payload without buffering it and infers
the stream's requirements. `HttpApiTest` passes stream payloads through
unbuffered. `OpenApi.fromApi` marks streaming request bodies with `x-

…[full
notes](https://github.com/Effect-TS/effect/releases/tag/%40effect/platform-node%404.0.6)

</details>

<details>
<summary><b>@<!---->tanstack/react-router</b> (1.170.45 →
1.170.46)</summary>

### Patch Changes

- [#8670](TanStack/router#8670)
[`32a3360`](TanStack/router@32a3360)
- Reference agent skills in other packages by their `intent load`
identifier (`@tanstack/<package>#<skill>`) instead of relative file
links that break once packages are installed.

- [#8671](TanStack/router#8671)
[`689a7c5`](TanStack/router@689a7c5)
- Publish the `@tanstack/react-router` agent skills (`react-router`,
`compositions/router-query`, `lifecycle/migrate-from-react-router`),
which were missing from the package's `files` list.

- Updated dependencies
\[[`32a3360`](TanStack/router@32a3360)]:
    -   @<!---->tanstack/[email protected]

</details>

<details>
<summary><b>@<!---->tanstack/react-start</b> (1.169.3 →
1.169.4)</summary>

### Patch Changes

- [#8670](TanStack/router#8670)
[`32a3360`](TanStack/router@32a3360)
- Reference agent skills in other packages by their `intent load`
identifier (`@tanstack/<package>#<skill>`) instead of relative file
links that break once packages are installed.

- Updated dependencies
\[[`32a3360`](TanStack/router@32a3360),
[`689a7c5`](TanStack/router@689a7c5),
[`ed55775`](TanStack/router@ed55775),
[`63a886d`](TanStack/router@63a886d),
[`d9b07e8`](TanStack/router@d9b07e8)]:
    -   @<!---->tanstack/[email protected]
    -   @<!---->tanstack/[email protected]
    -   @<!---->tanstack/[email protected]
    -   @<!---->tanstack/[email protected]
    -   @<!---->tanstack/[email protected]
    -   @<!---->tanstack/[email protected]
    -   @<!---->tanstack/[email protected]

</details>

<details>
<summary><b>effect</b> (4.0.5 → 4.0.6)</summary>

### Patch Changes

- [#9674](Effect-TS/effect#9674)
[`ce13a48`](Effect-TS/effect@ce13a48)
Thanks @<!---->effect-bot! - Allow `Response.AllParts`, `Response.Part`
and `Response.StreamPart` to be called without a toolkit, decoding tool
call and tool result parts for any tool name with `unknown` parameters
and results.

- [#9696](Effect-TS/effect#9696)
[`f3bbbb4`](Effect-TS/effect@f3bbbb4)
Thanks @<!---->gcanti! - Fix `Array.unionWith` calling custom
equivalence callbacks with values from the wrong input or in the wrong
order.

- [#9511](Effect-TS/effect#9511)
[`5547315`](Effect-TS/effect@5547315)
Thanks @<!---->sledorze! - Speed up field copying in `Data.Class`,
`Data.Error`, `Request.Class` and `Persistable` constructors.

- [#9743](Effect-TS/effect#9743)
[`6093cfb`](Effect-TS/effect@6093cfb)
Thanks @<!---->effect-bot! - Fix `AsyncResult` equality treating
unrelated `Equal` values with a matching tag and hash as equal.

- [#9607](Effect-TS/effect#9607)
[`30319d5`](Effect-TS/effect@30319d5)
Thanks @<!---->effect-bot! - Fix Effect atoms dropping the latest
exposed success when an asynchronous run fails, so an `initialValue` or
a success published with `get.setSelf` remains available as the
failure's previous success.

- [#9313](Effect-TS/effect#9313)
[`74a7596`](Effect-TS/effect@74a7596)
Thanks @<!---->effect-bot! - Preserve Reactivity and global layers when
replacing an atom runtime layer through registry initial values, so
injected test layers retain shared invalidation and global services.

- [#9190](https://github.com

…[full
notes](https://github.com/Effect-TS/effect/releases/tag/effect%404.0.6)

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

Atom: an Effect atom's first failure drops initialValue from previousSuccess, though a Stream atom keeps it

2 participants