oven-sh / bun

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

Bun run not exiting when calling prisma #12155

Open Tanavya opened 5 days ago

Tanavya commented 5 days ago

What version of Bun is running?

1.1.17

What platform is your computer?

Darwin 23.1.0 arm64 arm

What steps can reproduce the bug?

I literally just followed this guide. However, when I run bun run index.ts it doesn't exit! I noticed this on a different system as well, and on a different project where I am running prisma commands. If I do the same setup but with ts-node or tsx then it exits. Or if I add process.exit(0) at the end. https://bun.sh/guides/ecosystem/prisma

Basically this is my index.ts

import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

// create a new user
await prisma.user.create({
  data: {
    name: "John Dough",
    email: `john-${Math.random()}@example.com`,
  },
});

// count the number of users
const count = await prisma.user.count();
console.log(`There are ${count} users in the database.`);

What is the expected behavior?

It should exit gracefully without having to call process.exit(0).

What do you see instead?

No response

Additional information

No response

Tanavya commented 5 days ago

Okay just figured this out, downgrading to version bun version 1.1.0 works! But this is very weird and needs to be investigated soon! Thanks

Tanavya commented 5 days ago

Investigating further it seems something broke after version 1.1.13 since version 1.1.13 works but version 1.1.14 doesn't

Tanavya commented 5 days ago

I noticed a different use case in which my scripts don't exit even in older versions! This is really preventing me from using bun in our application, so it would be great if we get an update soon.

museadam commented 4 days ago

I cannot reproduce this error...I just tried bun 1.1.17 on one of my projects with prisma and it works fine for me...

Do you run bun install to ensure bun and not npm installed prisma? What does you package.json look like? Does your database build fine with npx prisma generate?

Jarred-Sumner commented 4 days ago

@Tanavya what database is it using? We have integration tests for postgres and sqlite, but I don't think we have integration tests for Prisma's mongodb or mysql adapters

Tanavya commented 3 days ago

I am using postgres for my own application which wasn't working, but even with the guide here (using sqlite) it doesn't work https://bun.sh/guides/ecosystem/prisma Here is a video of me performing all the steps

https://github.com/oven-sh/bun/assets/17531555/1297aef4-686b-4ce1-b1f0-811fdf8f4981