Open Fumaz opened 1 year ago
Confirming that a top-level await
here fixes the issue in Bun, but in Node.js this code would stay running:
bun-prisma on master [!] via 🐳 desktop-linux via 🍞 v1.0.0 via v18.16.0
❯ bun run index.ts
[0.03ms] ".env"
bun-prisma on master [!] via 🐳 desktop-linux via 🍞 v1.0.0 via v18.16.0
❯ npx tsx index.ts
PrismaClientKnownRequestError:
Invalid `database.user.create()` invocation in
/Users/dimgl/dev/playground/bun-prisma/index.ts:6:38
3 export const database = new PrismaClient({ datasourceUrl: "postgres://postgres:postgres@localhost:5433"});
4
5 async function main() {
→ 6 const user = await database.user.create(
The table `public.User` does not exist in the current database.
at vn.handleRequestError (/Users/dimgl/dev/playground/bun-prisma/node_modules/@prisma/client/runtime/library.js:123:6730)
at vn.handleAndLogRequestError (/Users/dimgl/dev/playground/bun-prisma/node_modules/@prisma/client/runtime/library.js:123:6119)
at vn.request (/Users/dimgl/dev/playground/bun-prisma/node_modules/@prisma/client/runtime/library.js:123:5839)
at l (/Users/dimgl/dev/playground/bun-prisma/node_modules/@prisma/client/runtime/library.js:128:9763)
at main (/Users/dimgl/dev/playground/bun-prisma/index.ts:6:18) {
code: 'P2021',
clientVersion: '5.2.0',
meta: { table: 'public.User' }
}
This happens in express middlewares as well
Same issue in my project. An async
function called on the top level without an await
doesn't prevent the process from exiting. My project has some scripts written before top-level await was available in nodejs.
What version of Bun is running?
1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983
What platform is your computer?
Darwin 23.0.0 arm64 arm
What steps can reproduce the bug?
docker compose up -d
bunx prisma migrate deploy
bunx prisma generate
bun run index.ts
What is the expected behavior?
User is created and logged in the console
What do you see instead?
As you can see, the user is not printed to the console. It looks like the code is not being executed.
Additional information
No response