@prisma/dev: WAL polling enters aborted socket transactions (25P02) and breaks shutdown
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- bun, postgresql, typescript
Research direction
Start with the supplied reproduction archive and its README, then run bun test repro.test.ts against the published package to confirm both failures. The report points to WAL polling, the socket queue and shutdown cleanup as the affected areas; the Prisma Dev source location is not identified. Done means polling waits for client transactions, shutdown cleans up clients before draining WAL, and the tests confirm committed rows appear once while rolled-back or disconnected writes do not appear.
Written by the indexing model from the issue text.
Description
Package and version
@prisma/[email protected] (current npm release), @electric-sql/[email protected]
What happened?
After a socket client commits a write, opens another transaction and receives an expected SQL error, internal WAL/Streams work queries the same PGlite instance while the client transaction is still aborted. It rejects with code 25P02: current transaction is aborted, commands ignored until end of transaction block. This also occurs during server.close() with an aborted client transaction and pending WAL work.
The independent reproduction has no ORM client, schema engine, application code, migrations or external database. Both cases fail on the unpatched published package and pass with the supplied downstream patches.
What did you expect to happen?
Internal WAL polling waits until the socket transaction commits, rolls back or disconnects. Shutdown disconnects/rolls back clients before draining WAL and closing PGlite. Committed rows reach Streams exactly once; rolled-back and disconnected uncommitted rows do not appear.
Minimal reproduction
Download reproduction and tested patches. The archive contains only the test, README, two manifests and exact-version patches; no application files, credentials, databases or node_modules. It is on an isolated reproduction branch, outside the socket PR.
unzip prisma-dev-wal-repro.zip
cd prisma-dev-wal-repro
bun install --ignore-scripts
bun test repro.test.ts
# unpatched: 0 passed, 2 failed with 25P02
cp package.patched.json package.json
bun install --ignore-scripts
bun test repro.test.ts
# patched: 2 passed, 0 failed (8 assertions)
The shutdown test creates a table, runs BEGIN; INSERT INTO wal_close_probe VALUES (1); COMMIT; BEGIN; SELECT 1 / 0, asserts the expected 22012 error, then calls server.close() before ending that client. The other test holds a failed transaction open while WAL polling runs, rolls it back, disconnects with another uncommitted write, and asserts that only the two committed rows appear once in Streams.
Environment
macOS arm64; reproduction runtime/package manager: Bun 1.4.4. Node 26.13.0 is installed but the Prisma reproduction was tested with Bun, not Node’s test runner. @prisma/dev 0.25.2 is the latest npm release checked for this report. Database: the embedded PGlite instance started by startPrismaDevServer, stateless, automatically assigned ports.
Additional context
Proposed source fix:
- Schedule internal WAL polling through the socket queue outside client transactions. db.runExclusive() alone serializes access, not transaction ownership.
- Dispatch subscribers after the polling work leaves the queue, avoiding reentrant queue deadlocks.
- Stop/disconnect clients before the final WAL poll and before closing database/Streams resources.
Companion socket source PR: https://github.com/electric-sql/electric-pglite/pull/1222 (runOutsideTransaction(), awaited handler cleanup, three regressions; 69/69 socket tests, build/typecheck/lint pass). Prisma Dev must adopt the primitive separately; the socket PR alone does not fix this consumer.
The archive provides tested patches against the exact published bundles as a reference, not generated files proposed for the ORM tree. I could not locate public source for @prisma/dev, and its published manifest declares no repository/bugs URL, so this report supplies the reproduction and fix for the appropriate owner. Please route it to the correct repository if necessary.
Validation: independent install, two failures without patches; same tests pass with only the two supplied patches. Downstream integration: 35/35 groups passed. This concerns local development/testing, not a production database.
- Dominant language
- TypeScript
- Stars
- 47.8k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 227
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from prisma/orm
-
bug/1-unconfirmed kind/bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
get-platform: distros with ID_LIKE=alpine are not detected as musl, so glibc engines are used on Alpine-based imagesPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
prisma/orm#31281 · 1 comment ·
Maintainers usually reply within 1 day
-
adapter-pg: connectToShadowDb connects to the main database when built from a connection stringMay be free again @cestercian claimed this 10 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
prisma/orm#31196 · 1 comment ·
Maintainers usually reply within 1 day
-
[Prisma 8] Type-check time grows exponentially with chained .include() callsPossibly taken @SiKreuz claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
prisma/orm#31161 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
prisma/orm#31125 · 4 comments · 6 reactions ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tenstorrent/ttnn-visualizer#2526 ·
Maintainers usually reply within 1 day
-
trySessionCache calls /get-session twice when minting session_data (cache miss or expired cookie)Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
neondatabase/neon-js#301 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
tashfeenahmed/freellmapi#2305 ·
Maintainers usually reply within 1 day