drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
22.11k stars 514 forks source link

[BUG]: Warning: async_hooks.createHook is not implanented in Bun. Hooks can still be created but will never be called. #2239

Open jonasfroeller opened 2 months ago

jonasfroeller commented 2 months ago

What version of drizzle-orm are you using?

0.30.9

What version of drizzle-kit are you using?

0.20.17

Describe the Bug

Bun doesn't support a feature drizzle-kit uses, but bun is an option in your documentation.
=> db pulling doesn't work using bun, meaning you have to use npm to excecute the drizzle-kit commands which leads to increased complexity, if you want to use drizzle-kit in github actions for example. (Because you need to convert the bun lockfile to a yarn lockfile meaning you have to setup yarn and then npm to execute the scripts in the package.json file).

image

Expected behavior

Bun supporting a feature you use in your code if you say it works with bun.

Environment & setup

npm v18 bun v1.1.6

jonasfroeller commented 2 months ago

I tried installing the packages needed for drizzle seperately too, so that I can use npm to run them, but I get unknown option '--config' doing so.

What I did: npm install --prefix ./drizzle/runner drizzle-orm drizzle-kit pg && npm run schema:push

... "schema:push": "drizzle-kit push:pg --config ../drizzle.config.ts", ...

j4w3ny commented 2 months ago

weird that older version of bun (bun v1.0.x) seems works fine with it.

uyrabi commented 1 month ago

I faced a similar issue as well.

bun: v1.1.10 drizzle-kit: v0.21.4 drizzle-orm: v0.30.10

When I ran bun drizzle-kit generate on an AWS Fargate, a warning was displayed and the table schema was not detected.

bun drizzle-kit generate
[bun] Warning: async_hooks.createHook is not implemented in Bun. Hooks can still be created but will never be called.
drizzle-kit: v0.21.4
drizzle-orm: v0.30.10

No config path provided, using default 'drizzle.config.ts'
Reading config file '/app/server/drizzle.config.ts'
Reading schema files:
/app/server/models/hoge/table.ts
/app/server/models/fuga/table.ts
...

0 tables

[✓] Your SQL migration file ➜ ...

Installing a relatively new version of nodejs allows bun drizzle-kit generate to work properly, but it is not a fundamental solution, so I am troubled.

BaptisteCrouzet commented 1 month ago

I have this issue too

drizzle-kit generate
[bun] Warning: async_hooks.createHook is not implemented in Bun. Hooks can still be created but will never be called.
drizzle-kit: v0.22.1
drizzle-orm: v0.31.0

No config path provided, using default 'drizzle.config.ts'
Reading config file '/usr/src/app/drizzle.config.ts'
0 tables

No schema changes, nothing to migrate 😴

With bun 1.1.12, here inside an alpine container. My schema come from the doc, with "user", and no migration was generated.

mi3lix9 commented 1 month ago

Same issue here

root@d5c658c5d72e:/workspaces/bot# bunx drizzle-kit generate:sqlite --schema ./schema.ts
[bun] Warning: async_hooks.createHook is not implemented in Bun. Hooks can still be created but will never be called.
error: unknown option '--schema'

using oven/bun:debian

1337hero commented 1 month ago

RIP I came looking and found these issues. Same:

drizzle-kit: v0.22.5
drizzle-orm: v0.31.2

Bun -v 1.1.12 drizzle-kit: v0.22.5 drizzle-orm: v0.31.2

You know what's wild? https://nodejs.org/api/async_hooks.html -> _We strongly discourage the use of the async_hooks API. Other APIs that can cover most of its use cases include:_

Node documentation literally suggests not using this API.

ludersGabriel commented 1 week ago

as mentioned by @uyrabi, drizzle-kit will work normally ifi you have a new enough version of node installed.

I just formatted my pc, cloned the repo I was working on and installed only bun and docker. Started getting this weird error out of nowhere, tried a bunch of stuff like rolling back bun versions and drizzle versions but couldn´t get it to work. Installed node lts with nvm install --lts, rebooted, everything works fine. Crazy.

zereraz commented 1 week ago

@ludersGabriel It is exactly as you said. my server didn't have nodejs installed and I did bunx drizzle-kit generate and it didn't work I installed nodejs, sudo apt install nodejs bunx drizzle-kit generate this worked now. then to confirm, uninstall nodejs sudo apt-get remove nodejs empty the migration folder and bunx drizzle-kit generate again stops working.