Skip to content

@effect/sql-sqlite-do SqlClient.withTransaction is incompatible with Durable Object SQLite (workerd) #6006

@mykola-vrmchk

Description

@mykola-vrmchk

What version of Effect is running?

  • @effect/sql: 0.49
  • @effect/sql-sqlite-do: 0.27.0
  • effect: 3.19.13
  • Runtime: Cloudflare Workers / workerd Durable Objects with SQLite

What steps can reproduce the bug?

Here is minimal repro
https://github.com/mykola-vrmchk/effect-sqlite-do-tx-repro

1. Run and observe

pnpm install
pnpm wrangler dev --local

2. In another terminal:

curl -i http://localhost:8787/no-tx
curl -i http://localhost:8787/tx

3. Summary

On Cloudflare Durable Objects with SQLite (state.storage.sql), SQL-managed transactions are forbidden (e.g. BEGIN, COMMIT, ROLLBACK). However SqlClient.withTransaction(...) in @effect/sql implements transactions by issuing those SQL statements. As a result, using @effect/sql-sqlite-do inside a Durable Object causes withTransaction to fail at runtime.

What is the expected behavior?

  • @effect/sql-sqlite-do provides a Durable Object–aware transaction implementation that uses state.storage.transaction(...) (i.e., not SQL statements)

What do you see instead?

  • /no-tx succeeds (basic queries work).
  • /tx fails (500), because withTransaction tries to execute BEGIN/COMMIT/ROLLBACK via DO SQLite, which workerd forbids. The error is commonly wrapped as SqlError: Failed to execute statement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions