drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]: Closing drizzle-studio with ctrl+c causes corrupted PGLite database

Open robertlong opened this issue 1 year ago • 0 comments

What version of drizzle-orm are you using?

0.33.0

What version of drizzle-kit are you using?

0.24.2

Describe the Bug

After running a few DELETE FROM commands in the query runner in Drizzle Studio, I must have closed the cli too early, because upon running my server again I got the following error from PGLite:

RuntimeError: Aborted(). Build with -sASSERTIONS for more info.
              at abort (/Users/robertlong/Workspace/sidekick-server/node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/postgres.js:740:11)
              at __abort_js (/Users/robertlong/Workspace/sidekick-server/node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/postgres.js:7244:7)
              at postgres.wasm.abort (wasm://wasm/postgres.wasm-02856b0a:wasm-function[14927]:0x6db55a)
              at postgres.wasm.errfinish (wasm://wasm/postgres.wasm-02856b0a:wasm-function[5153]:0x205c39)
              at postgres.wasm.InitWalRecovery (wasm://wasm/postgres.wasm-02856b0a:wasm-function[11909]:0x52ce57)
              at postgres.wasm.StartupXLOG (wasm://wasm/postgres.wasm-02856b0a:wasm-function[11579]:0x5076b2)
              at postgres.wasm.InitPostgres (wasm://wasm/postgres.wasm-02856b0a:wasm-function[874]:0x98cb8)
              at postgres.wasm.AsyncPostgresSingleUserMain (wasm://wasm/postgres.wasm-02856b0a:wasm-function[6038]:0x264cbc)
              at postgres.wasm.pg_initdb (wasm://wasm/postgres.wasm-02856b0a:wasm-function[8324]:0x341265)
              at Object.Module._pg_initdb (/Users/robertlong/Workspace/sidekick-server/node_modules/.pnpm/@[email protected]/node_modules/@electric-sql/pglite/dist/postgres.js:10397:109)

The last time I saw this error, it was when I forgot to call await pg.close() in my migration script. I expect this is for similar reasons.

Expected behavior

Upon receiving a termination signal, the drizzle-studio should close the database connection gracefully. The close-with-grace package could help with this.

Environment & setup

Local node.js 22 macOS development environment with PGLite.

robertlong avatar Sep 28 '24 00:09 robertlong