Skip to content

Expose outer interactive transaction outcome to afterTransaction hooks #899

Description

@borisno2

Problem

A list write executed through the transaction context passed to context.transaction(async (tx) => ...) runs its afterTransaction hook as soon as that individual write pipeline returns. The outer transaction callback can still perform later writes or throw, so an external side effect launched by that hook can escape even though the surrounding interactive transaction ultimately rolls back.

The transaction-scoped Prisma client has no $transaction method, so applications can currently detect this shape and defer dispatch manually until context.transaction() resolves, but that is an undocumented and fragile workaround.

Requested API/behavior

Please either:

  • defer nested list afterTransaction hooks until the owning context.transaction() settles, supplying its committed/rolled-back outcome; or
  • expose an explicit supported signal that the list write is nested in an outer interactive transaction so applications can safely coordinate after-commit effects.

Context

Found while fixing application issue borisno2/emily-calder-performing-arts#2992. Direct writes can use the existing committed afterTransaction pattern, while trial conversion and rollover currently require explicit post-transaction() dispatch to guarantee rollback safety.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions