Skip to content

fix(adapter-libsql): clean up failed commits - #30071

Open
GiHoon1123 wants to merge 1 commit into
prisma:v7from
GiHoon1123:fix/adapter-libsql-zombie-transaction
Open

fix(adapter-libsql): clean up failed commits#30071
GiHoon1123 wants to merge 1 commit into
prisma:v7from
GiHoon1123:fix/adapter-libsql-zombie-transaction

Conversation

@GiHoon1123

@GiHoon1123 GiHoon1123 commented Aug 19, 2026

Copy link
Copy Markdown

Fixes #30028

When the libsql adapter uses phantom transactions, the transaction manager delegates the actual COMMIT/ROLLBACK calls to the adapter. If COMMIT fails, the underlying libsql transaction can remain open unless the adapter explicitly cleans it up.

This updates LibSqlTransaction.commit() to attempt a rollback after a failed commit. If that cleanup rollback also fails, it closes the transaction handle as a fallback while preserving the original commit error.

Tests:

  • pnpm --filter @prisma/adapter-libsql test
  • pnpm --filter @prisma/adapter-libsql build

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 42ac2a99-45ec-4ced-83d2-93e3f13a4835

📥 Commits

Reviewing files that changed from the base of the PR and between 05ce490 and b2a2fc5.

📒 Files selected for processing (2)
  • packages/adapter-libsql/src/libsql.test.ts
  • packages/adapter-libsql/src/libsql.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Changes

LibSQL commit failure recovery

Layer / File(s) Summary
Commit cleanup and failure coverage
packages/adapter-libsql/src/libsql.ts, packages/adapter-libsql/src/libsql.test.ts
Failed commits attempt rollback. If rollback fails, the transaction client is closed and secondary failures are logged. The original commit error is rethrown. Tests cover successful rollback and rollback-plus-close failures.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to b2a2f

The change cleans up libsql transactions after failed commits while preserving the original error, with focused tests and build coverage; no actionable merge-blocking risk remains.

Possibly related PRs

  • prisma/prisma#28768: Both changes handle rollback and resource cleanup after transaction failures.
  • prisma/prisma#29611: Both changes attempt rollback and close cleanup when transaction cleanup fails.
  • prisma/prisma#29955: Both changes recover from commit failures while preserving the original error.

Suggested labels: lgtm

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR fixes failed-commit cleanup but does not implement the linked issue's separate requirement for a dedicated SQLITE_BUSY error kind. Add the required SQLITE_BUSY error classification, or explicitly narrow the linked issue scope if another change handles it.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The implementation and tests remain focused on failed-commit rollback, transaction closure, and preservation of the original error.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: cleanup handling for failed libsql transaction commits.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

2 participants