Describe the bug
PGlite processes wire-protocol messages one at a time. When a Parse message fails, PGlite emits ErrorResponse + ReadyForQuery immediately — before the client's Sync arrives. Standard PostgreSQL only emits ReadyForQuery in response to Sync. This gave Prisma's schema engine two ReadyForQuery messages where it expected one, desynchronising its message pipeline and producing P1017.
To Reproduce
https://github.com/Tobbe/repro-pglite-p1017
See the README in that repo for exact reproduction steps
Logs
If applicable, include logs (ideally as text, not screenshots) that you gathered.
Details
- PGlite version: 0.4.2
- using any extensions? which ones?: No
- OS version: macOS 15.2
- node, bun, deno or browser version: Node 24.14.1
Additional context
The bug was identified by Claude Sonnet 4.6.
The reproduction was generated by MiMo V2 Pro Free. It took me and the LLM three iterations to arrive at an (imo) acceptable repro.
I had Sonnet arrive at the bug twice, in totally separate apps with no prior knowledge of the issue.
The second time it gave this explanation:
Now I fully understand the bug. Here's what's happening:
- The schema engine sends Parse + Describe + Sync as a batch in 196 bytes
pglite-socket splits them and sends each message one at a time to execProtocolRawStream
- PGlite processes
Parse alone → returns ErrorResponse + ReadyForQuery (it generates ReadyForQuery immediately, which is wrong — in the real PG protocol, ReadyForQuery only comes from a Sync)
- PGlite processes
Describe → returns 0 bytes (nothing to describe for a failed parse, but no error/NoData sent)
- PGlite processes
Sync → returns another ReadyForQuery
The schema engine's tokio-postgres receives an extra unexpected ReadyForQuery and its protocol state machine gets corrupted, which surfaces later as P1017.
Other
The reproduction repo also has a "fix"/workaround that might be helpful
Describe the bug
PGlite processes wire-protocol messages one at a time. When a
Parsemessage fails, PGlite emitsErrorResponse + ReadyForQueryimmediately — before the client'sSyncarrives. Standard PostgreSQL only emitsReadyForQueryin response toSync. This gave Prisma's schema engine twoReadyForQuerymessages where it expected one, desynchronising its message pipeline and producing P1017.To Reproduce
https://github.com/Tobbe/repro-pglite-p1017
See the README in that repo for exact reproduction steps
Logs
If applicable, include logs (ideally as text, not screenshots) that you gathered.
Details
Additional context
The bug was identified by Claude Sonnet 4.6.
The reproduction was generated by MiMo V2 Pro Free. It took me and the LLM three iterations to arrive at an (imo) acceptable repro.
I had Sonnet arrive at the bug twice, in totally separate apps with no prior knowledge of the issue.
The second time it gave this explanation:
Other
The reproduction repo also has a "fix"/workaround that might be helpful