Skip to content

Expose attempt and retry metadata on Effect.Transaction - #8166

Open
KhraksMamtsov wants to merge 6 commits into
Effect-TS:mainfrom
KhraksMamtsov:tx-meta
Open

KhraksMamtsov wants to merge 6 commits into
Effect-TS:mainfrom
KhraksMamtsov:tx-meta

Conversation

@KhraksMamtsov

@KhraksMamtsov KhraksMamtsov commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Effect.Transaction now carries attempt metadata, analogous to Schedule.CurrentMetadata. Yield it inside a transaction body to read attempt, retryReason, and timing fields (start, now, elapsed, elapsedSincePrevious).

import { Effect, TxRef } from "effect"

const program = Effect.gen(function*() {
  const ref = yield* TxRef.make(0)

  return yield* Effect.tx(Effect.gen(function*() {
    const tx = yield* Effect.Transaction

    // attempt: 1, 2, 3, ...
    // retryReason: undefined | "retry" | "conflict"
    // elapsed / elapsedSincePrevious: milliseconds from Clock (TestClock in tests)
    console.log(tx.attempt, tx.retryReason, tx.elapsed, tx.elapsedSincePrevious)

    const value = yield* TxRef.get(ref)
    if (value === 0) {
      return yield* Effect.txRetry
    }
    return value
  }))
})

Related

  • Related Issue #
  • Closes #

@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 84d3d09

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

This PR includes changesets to release 30 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter 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/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

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

Labels

4.0 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants