oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
71.71k stars 2.54k forks source link

bun:sqlite not closable after running migrations #11418

Open pekeler opened 1 month ago

pekeler commented 1 month ago

What version of Bun is running?

1.1.10

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

import { migrate } from "drizzle-orm/bun-sqlite/migrator";
import { drizzle } from "drizzle-orm/bun-sqlite";
import { Database } from "bun:sqlite";

const sqlite = new Database("sqlite.db");
const db = drizzle(sqlite);
migrate(db, { migrationsFolder: "./drizzle" });
sqlite.close(true);

What is the expected behavior?

No error, db is closed.

What do you see instead?

error: database is locked

Additional information

Repro: https://github.com/pekeler/bun-lite

jnatmorris commented 2 weeks ago

As per the documentation "To close a database connection, but allow existing queries to finish, call .close(false):". Unfortunately this does not work for me as I'm running into the same bug, but just when executing many insert statements in quick succession.