electric-sql / pglite

Lightweight Postgres packaged as WASM into a TypeScript library for the browser, Node.js, Bun and Deno
https://electric-sql.com
Apache License 2.0
4.76k stars 81 forks source link

Throw error when main db instance method used inside an interactive transaction #76

Open denis-sepirak opened 2 months ago

denis-sepirak commented 2 months ago
const client = new PGlite();
await client.transaction(async (tx) => {
   await tx.query('select 1');
   await client.query('select 1'); // process just exits without any errors
}) 

Is this an intended behavior? (I know that I shouldn't do this, but still)

$ node -v
v20.11.0
$ arch
arm64
samwillis commented 2 months ago

Hey @denis-sepirak Yep, using the client instance inside an interactive transaction is not supported. There is no specific error handling for it apart from a Mutex at the moment, it may be that it's deadlocking.

I'm going to repurpose this issue to track adding error handling to this situation.