Hello. I'm attempting to use Prisma with Bun, however I notice that it immediately kills any script that it is run with. I've installed Prisma correctly and have setup my .env file with a local PostgreSQL database. Running bunx prisma generate, bunx prisma db push, and bunx prisma validate works fine. This is my code:
import dotenv from "dotenv";
dotenv.config();
import { PrismaClient } from "@prisma/client";
const url = process.env.DATABASE_URL;
console.log(`Database URL: ${url}`); // Database URL: postgresql://postgres:password@localhost:5432/?connection_limit=100
const prisma = new PrismaClient();
prisma.$connect().then(async (_) => {
console.log("Connected to database"); // Never logs
});
I know for a fact that everything works as I have uninstalled and reinstalled PostgreSQL, upgraded my Bun version to both the stable and canary version, etc. The problem is that "Connected to database" is never logged. I've used similar code on a larger scale and encounter the same issue:
// Other file
export const init = async() => {
// Do things with prisma
};
// index.ts
init(); // Process is killed here
doSomethingElse(); // never runs