Fix execProtocolRawSync spin after backend exit - #1081
Conversation
|
I reproduced #1058 independently before I noticed this PR existed, and ended up with a patch of my own. Since you got here first and your fix is sound, I am not going to open a competing PR — but I gathered a few things while verifying it that seem worth handing over rather than throwing away. Independent reproduction and an instrumented trace
1.6M+ iterations in 20s at 100%+ CPU before I killed it. So the sequence your first clause keys on ( One incidental note for anyone writing tests here: your child-process approach is the right call. I naively put the reproduction in a normal vitest file, and because the spin is synchronous, vitest's 30s A possible gap:
|
작업 배경
execProtocolRawSyncswallowed exceptions from the Postgres WASM main loop unless they matched the database error longjmp sentinel. When the backend exited or crashed mid-message, the input offsets stopped advancing and the synchronous loop retried forever at 100% CPU.티켓 및 링크
작업 내용
ExitStatus,RuntimeError, and other exceptions outside the known longjmp recovery path.process.exitCode.@electric-sql/pglite.테스트
pnpm --dir packages/pglite exec vitest run tests/exec-protocol-backend-exit.test.ts tests/exec-protocol.test.ts --reporter=verbosepnpm --dir packages/pglite exec vitest run tests/basic.test.ts --testNamePattern='restores process.exitCode' --reporter=verbosepnpm --dir packages/pglite typecheckpnpm --dir packages/pglite stylecheck