Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transactions in sql-libsql do not work #3709

Closed
jkonowitch opened this issue Sep 30, 2024 · 0 comments · Fixed by #3720
Closed

Transactions in sql-libsql do not work #3709

jkonowitch opened this issue Sep 30, 2024 · 0 comments · Fixed by #3720
Labels
bug Something isn't working

Comments

@jkonowitch
Copy link
Contributor

What version of Effect is running?

3.8.4

What steps can reproduce the bug?

When working against a live Libsql database, transactions as currently implemented do not work.

Test code here:

https://github.com/Effect-TS/effect/compare/main...jkonowitch:effect:libsql-failing-transactions?expand=1

What is the expected behavior?

Tests should pass

What do you see instead?

 DEV  v2.0.5 /home/jeff/dev/effect/packages/sql-libsql

 ❯ test/Client.test.ts (4) 2620ms
   ❯ Client (4) 2620ms
     ✓ should work
     ✓ should work with raw
     × withTransaction 1958ms
     × withTransaction rollback 2620ms
 ✓ test/Resolver.test.ts (6) 1847ms

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/Client.test.ts > Client > withTransaction
 FAIL  test/Client.test.ts > Client > withTransaction rollback
SqlError: Failed to execute statement
 ❯ catch src/LibsqlClient.ts:119:29
    117|         Effect.tryPromise({
    118|           try: () => db.execute({ sql, args: params as Array<any> }).then((results) => results.rows),
    119|           catch: (cause) => new SqlError({ cause, message: "Failed to execute statement" })
       |                             ^
    120|         })
    121| 
 ❯ ../effect/src/internal/core-effect.ts:1694:56

Caused by: LibsqlError: SQLITE_UNKNOWN: SQLite error: cannot commit - no transaction is active
 ❯ mapHranaError ../../node_modules/.pnpm/@libsql+client@0.12.0/node_modules/@libsql/client/lib-esm/hrana.js:268:16
 ❯ ../../node_modules/.pnpm/@libsql+client@0.12.0/node_modules/@libsql/client/lib-esm/http.js:76:23

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { span: undefined, code: 'SQLITE_UNKNOWN', rawCode: undefined }
Caused by: ResponseError: SQLite error: cannot commit - no transaction is active
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { span: undefined, code: 'SQLITE_UNKNOWN', proto: { message: 'SQLite error: cannot commit - no transaction is active', code: 'SQLITE_UNKNOWN' } }
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯

 Test Files  1 failed | 1 passed (2)
      Tests  2 failed | 8 passed (10)
   Start at  16:15:08
   Duration  5.84s (transform 2.02s, setup 1.73s, collect 4.12s, tests 4.47s, environment 0ms, prepare 94ms)

Additional information

No response

@jkonowitch jkonowitch added the bug Something isn't working label Sep 30, 2024
thewilkybarkid added a commit to PREreview/prereview.org that referenced this issue Oct 3, 2024
There's a bug in the `@effect/sql-libsql` library where transactions don't work with a libSQL server. This has broken in the sandbox, but not locally where SQLite is used. This commit removes transactions temporarily to allow the sandbox to be used, as it's still feature-flagged and is solely for testing at the moment.

Refs #1973, b041ac1, Effect-TS/effect#3709
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant