bun icon indicating copy to clipboard operation
bun copied to clipboard

bunx prisma generate hangs indefinitely on v1.1.30 but works fine on v1.1.29

Open Eldar-X opened this issue 1 year ago • 18 comments

What version of Bun is running?

1.1.30+7996d06b8

What platform is your computer?

Linux 6.8.0-1013-oracle aarch64 aarch64

What steps can reproduce the bug?

1- Install Bun v1.1.30. 2- Run bunx prisma generate.

What is the expected behavior?

bunx prisma generate should successfully generate Prisma files and exit without hanging.

What do you see instead?

On Bun v1.1.30, the process hangs indefinitely and never completes.

Additional information

This issue only occurs on v1.1.30. The exact same command works fine on v1.1.29.

Eldar-X avatar Oct 13 '24 19:10 Eldar-X

I can reproduce this issue as well, but when I upgraded to the canary version, it seemed to work again. Does upgrading with:

bun upgrade --canary

resolve the issue for you too?

RiskyMH avatar Oct 14 '24 00:10 RiskyMH

Unfortunately, the same problem persists for me in canary.

Eldar-X avatar Oct 15 '24 01:10 Eldar-X

Haven't been able to reproduce this locally, however I think this has been wrecking my my docker build causing the prisma generate step to silently fail. Had to use imbios/bun-node as the base instead of oven/bun

derekhearst avatar Oct 16 '24 16:10 derekhearst

I'm also having the same issue. I'm using Windows and bun hangs with versions 1.1.30, 1.1.31, 1.1.32 and the latest canary build, everything works fine with version 1.1.29.

4loris4 avatar Oct 22 '24 07:10 4loris4

the same :'( on macos

gouz avatar Nov 14 '24 17:11 gouz

I have not fixed it and not sure this is the same but on MacOS: it just stopped working as well after I upgraded bun. Trying to downgrade to test...

bligneri avatar Nov 14 '24 19:11 bligneri

The way I work now is as follows. First I downgrade to version 1.1.29, then I migrate and generate client. In order to start the seeding process, I have to upgrade to the latest version again, because v1.1.29 seeding process ends the process directly without waiting for the seeding process to finish. As you can understand, there is a very problematic workflow.

Eldar-X avatar Nov 14 '24 22:11 Eldar-X

@nektro will start working on fixing this soon

Jarred-Sumner avatar Nov 14 '24 22:11 Jarred-Sumner

Hello, today I read that some bugs related to prisma were solved in v1.1.37 version, but the prisma generate command is still stuck. I just wanted to remind you of this problem.

Eldar-X avatar Nov 27 '24 16:11 Eldar-X

FWIW https://github.com/prisma/prisma/issues/25730

mzdr avatar Nov 30 '24 23:11 mzdr

I can confirm that canary does not fix anything, and that the infinite silent hang in my docker builds was solved by pinning the base image to oven/bun:1.1.29

skylarmb avatar Dec 04 '24 19:12 skylarmb

Working today with prisma@latest (6.0.1)

gouz avatar Dec 04 '24 19:12 gouz

PR #15629 should fix this.

heimskr avatar Dec 07 '24 02:12 heimskr

is this fixed? I am using bun version 1.1.39, but still stuck when runs bunx prisma generate

alisholihindev avatar Dec 10 '24 06:12 alisholihindev

that pr is available if you use bun upgrade --canary but has not made it into a release yet

nektro avatar Dec 10 '24 07:12 nektro

When I try it with Bun Canary, the situation looks the same.

  • bun upgrade --canary
  • bun prisma generate

Message: "Environment variables loaded from .env Prisma schema loaded from src"

after that it's stuck.

Eldar-X avatar Dec 11 '24 07:12 Eldar-X

@Eldar-X canary builds weren't running last week unfortunately, can you give it another try?

Our next step before closing this is to add an integration test that runs prisma generate with --bun

Jarred-Sumner avatar Dec 17 '24 02:12 Jarred-Sumner

I upgraded to canary version again but unfortunately there is no change.

Eldar-X avatar Dec 17 '24 11:12 Eldar-X

$ prisma gen
============================================================
Bun Canary v1.1.41-canary.29 (b8f28ed8) Linux x64
WSL Kernel v5.15.167 | glibc v2.36
CPU: sse42 popcnt avx avx2 avx512
Args: "node" "/home/i/_/nito-projects/node_modules/.bin/prisma" "gen"
Features: dotenv jsc transpiler_cache(4) tsconfig(2) tsconfig_paths 
Builtins: "bun:main" "node:fs" "node:string_decoder" "node:util/types" 
Elapsed: 76ms | User: 59ms | Sys: 19ms
RSS: 1.07GB | Peak: 60.45MB | Commit: 1.07GB | Faults: 0

panic(main thread): Segmentation fault at address 0x0
Crashed while visiting /home/i/_/nito-projects/node_modules/@prisma/get-platform/dist/chunk-6HZWON4S.js
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.41/ln2b8f28edChw/7//BoqkumE+kgP06rjoDqt4miDqz20hD+s45gDy364gDkhn6gD40vs+D_A2AA

akirarika avatar Dec 20 '24 16:12 akirarika

Still hangs, with latest canary build..

rizrmd avatar Jan 13 '25 05:01 rizrmd

There doesn't seem to be any progress on this issue for a long time. I hope it doesn't get lost among other issues.

Eldar-X avatar Jan 20 '25 19:01 Eldar-X

I was also hitting this, as a workaround, I installed node on my image as suggested here on Discord: https://discord.com/channels/876711213126520882/876711213126520885/1305786915445932124, then running prisma generate worked for me

coreh avatar Jan 21 '25 18:01 coreh

This is a bug in child_process.fork. I can reproduce it by running node's parallel/test-child-process-* test cases.

Edit: I'm seeing a hang when passing dgram sockets to child processes. This may or may not be related. cc @heimskr

DonIsaac avatar Feb 27 '25 07:02 DonIsaac

In my case, I used to have a wrapper script around Prisma so that Prisma would use Bun-loaded .env, .env.local etc. variables rather than just its own mechanic for loading only .env.

This was it:

import Bun from 'bun';

const argv = [process.argv0, 'node_modules/.bin/prisma', ...process.argv.slice(2)];

const { exitCode } = Bun.spawnSync(argv, {
  stdio: ['inherit', 'inherit', 'inherit'],
  windowsHide: true
});

process.exitCode = exitCode;

And I had the same hanging issue. In the meantime Bun shell was out so I did this and this behaves virtually the same but does not hang:

import { $ } from 'bun';

const { exitCode } = await $`prisma ${process.argv.slice(2)}`.nothrow();

process.exit(exitCode);

Add an package.json script with ex. "prisma": "bun prisma/run-prisma.ts" and now you can bun prisma <command>!

toverux avatar Mar 13 '25 21:03 toverux

bun 1.2.5 still met the same issue

whchi avatar Mar 18 '25 08:03 whchi

Seems strongly correlated to https://github.com/oven-sh/bun/issues/17767 for those running devcontainers or containerized CIs.

zktaiga avatar Mar 27 '25 16:03 zktaiga

This fix works for me:

bunx prisma generate | cat

Found here: https://github.com/prisma/prisma/issues/25730#issuecomment-2717853330

enesbala5 avatar Jul 28 '25 14:07 enesbala5