drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]: drizzle-kit [email protected] Hangs After Reading Config on macOS (Node v20)

Open polychlorinated opened this issue 1 year ago • 15 comments

Report hasn't been filed before.

  • [x] I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.43.0

What version of drizzle-kit are you using?

0.31.0

Other packages

No response

Describe the Bug

When running the drizzle-kit migrate command (specifically version 0.31.0, the latest published on npm as of 2025-04-24), the process consistently hangs indefinitely after logging "Using 'pg' driver for database querying". It occurs before any apparent database interaction related to migrations (like checking or creating the __drizzle_migrations table or applying SQL). The hang happens even with freshly generated migration files after a database reset.

Steps to Reproduce:

Set up a project using Drizzle ORM with PostgreSQL. Ensure package.json specifies "type": "module". Install dependencies, specifically: [email protected] [email protected] [email protected] Configure drizzle.config.ts with standard settings (schema path, out path, dialect: "postgresql", dbCredentials from process.env.DATABASE_URL). Ensure .env file contains a valid DATABASE_URL for a running PostgreSQL database. Generate at least one migration file using drizzle-kit generate (e.g., migrations/0000_....sql). Run the migration command, for example: npx dotenv-cli -e .env -- npx drizzle-kit migrate --config=./drizzle.config.ts (or via npm run db:migrate).

Expected Behavior:

The drizzle-kit migrate command should:

Read the config. Connect to the database. Check for the __drizzle_migrations table (creating it if necessary). Compare migration files in the migrations folder with records in the table. Apply any pending migrations. Report success or failure.

Actual Behavior:

The command outputs the following and then hangs indefinitely:

Reading config file '/path/to/your/drizzle.config.ts'
[drizzle.config.ts] DATABASE_URL: postgresql://user:********@host:port/db
Using 'pg' driver for database querying
(...hangs here...)

No further output is produced in the terminal. PostgreSQL logs (with log_statement = 'all' enabled) show no connection attempt from this specific migrate command process.

Environment:

OS: macOS (Apple Silicon, using Homebrew) Node.js: v20.19.1 (LTS) npm: 10.x (corresponding to Node v20) drizzle-kit: 0.31.0 drizzle-orm: 0.43.0 pg: 8.15.5 Database: PostgreSQL v14 (via Homebrew)

Relevant Configuration:

package.json (devDependencies):
json
  "devDependencies": {
    // ... other devDependencies ...
    "drizzle-kit": "^0.31.0",
    "drizzle-orm": "^0.43.0",
    // ...
  },

drizzle.config.ts:

typescript
import { defineConfig } from "drizzle-kit";

if (!process.env.DATABASE_URL) {
  throw new Error("DATABASE_URL environment variable is not set.");
}

export default defineConfig({
  schema: "./shared/schema.ts", // Or your schema path
  out: "./migrations",
  dialect: "postgresql",
  dbCredentials: {
    url: process.env.DATABASE_URL,
  },
  verbose: true, // Tried with true/false
  strict: true,  // Tried with true/false
});

Troubleshooting Steps Taken:

Confirmed database connection works fine using psql with the exact same DATABASE_URL. Confirmed Node.js pg driver connects and queries successfully using a minimal test script. Confirmed drizzle-kit push command works correctly (connects, reads schema, reports no changes). Switched from Node v23 (unstable) to v20 (LTS), including full rm -rf node_modules && rm package-lock.json && npm install. Performed multiple clean installs. Verified file permissions for migration files and folders. Confirmed Node.js can read migration files using fs.readFile. Isolated the hang: It occurs only when .sql files are present in the migrations folder. It occurs even if only the first CREATE TABLE statement from a migration file is present. It occurs even after manually re-typing the SQL statement to rule out hidden characters. Performed a "hard reset": Dropped all DB tables (including __drizzle_migrations), deleted the migrations folder, ran drizzle-kit generate to create a new initial migration file. The hang still occurred with [email protected] when trying to run migrate on this fresh file. Confirmed [email protected] is not published on npm; 0.31.0 is the latest as of this report. Downgrading to [email protected] does not hang but shows an "outdated version" message, indicating the hang is specific to 0.31.0 (or versions between 0.23.2 and 0.31.0).

Conclusion:

The drizzle-kit migrate command in version 0.31.0 appears to have a bug causing it to hang during the initial file processing/parsing stage on macOS with Node v20, before attempting database operations. The issue is not related to database connectivity, credentials, file permissions, or the specific content of the SQL (as even freshly generated files trigger it), but seems tied to this specific version and environment combination.

polychlorinated avatar Apr 24 '25 18:04 polychlorinated

Same issue here, any news?

cesarvarela avatar May 07 '25 17:05 cesarvarela

When running the command via the JavaScript Debug Terminal, the expected output is shown 🤔

[✓] migrations applied successfully!

cesarvarela avatar May 07 '25 17:05 cesarvarela

Did you ever figure this out? I'm facing the same issue

gabro avatar Jul 23 '25 13:07 gabro

Same on Bun.

alpharder avatar Aug 04 '25 17:08 alpharder

Facing the same issue here

Endmostcamera32 avatar Aug 06 '25 05:08 Endmostcamera32

hello, same issue here, any solution please? macOs bun 1.2.5 honojs drizzle-orm 0.44.4 drizzle-kit 0.31.4 😭

sutejakw avatar Aug 07 '25 05:08 sutejakw

Had similar issue with migration on a Linux VPS, turned out to be out-of-memory issue. Assigned more RAM to the VM and it worked.

Not sure if that helps in this situation, but posting in case it does.

burtek avatar Aug 07 '25 05:08 burtek

In my case the issue was caused by nvm. Removing nvm and using a Node installed via brew fixed it for me

gabro avatar Aug 07 '25 05:08 gabro

I also fixed it by using "drizzle-kit": "^0.30.5" instead of "drizzle-kit": "^0.31.4".

Didn't change anything else.

Endmostcamera32 avatar Aug 07 '25 05:08 Endmostcamera32

I also fixed it by using "drizzle-kit": "^0.30.5" instead of "drizzle-kit": "^0.31.4".

Didn't change anything else.

this working on me, thanks a lot

sutejakw avatar Aug 07 '25 05:08 sutejakw

Hey everyone!

I've created this message to send in a batch to all opened issues we have, just because there are a lot of them and I want to update all of you with our current work, why issues are not responded to, and the amount of work that has been done by our team over ~8 months.

I saw a lot of issues with suggestions on how to fix something while we were not responding – so thanks everyone. Also, thanks to everyone patiently waiting for a response from us and continuing to use Drizzle!

We currently have 4 major branches with a lot of work done. Each branch was handled by different devs and teams to make sure we could make all the changes in parallel.


First branch is drizzle-kit rewrite

All of the work can be found on the alternation-engine branch. Here is a PR with the work done: https://github.com/drizzle-team/drizzle-orm/pull/4439

As you can see, it has 167k added lines of code and 67k removed, which means we've completely rewritten the drizzle-kit alternation engine, the way we handle diffs for each dialect, together with expanding our test suite from 600 tests to ~9k test units for all different types of actions you can do with kit. More importantly, we changed the migration folder structure and made commutative migrations, so you won't face complex conflicts on migrations when working in a team.

What's left here:

  • We are finishing handling defaults for Postgres, the last being geometry (yes, we fixed the srid issue here as well).
  • We are finishing commutative migrations for all dialects.
  • We are finishing up the command, so the migration flow will be as simple as drizzle-kit up for you.

Where it brings us:

  • We are getting drizzle-kit into a new good shape where we can call it [email protected]!

Timeline:

  • We need ~2 weeks to finish all of the above and send this branch to beta for testing.

Second big branch is a complex one with several HUGE updates

  • Bringing Relational Queries v2 finally live. We've done a lot of work here to actually make it faster than RQBv1 and much better from a DX point of view. But in implementing it, we had to make another big rewrite, so we completely rewrote the drizzle-orm type system, which made it much simpler and improved type performance by ~21.4x:
(types instantiations for 3300 lines production drizzle schema + 990 lines relations)

TS v5.8.3: 728.8k -> 34.1k
TS v5.9.2: 553.7k -> 25.4k

You can read more about it here.

What's left here:

Where it brings us:

  • We are getting drizzle-orm into a new good shape where we can call it [email protected]!

Breaking changes:

  • We will have them, but we will have open channels for everyone building on top of drizzle types, so we can guide you through all the changes.

Third branch is adding support for CockroachDB and MSSQL dialects

Support for them is already in the alternation-engine branch and will be available together with the drizzle-kit rewrite.

Summary

All of the work we are doing is crucial and should be done sooner rather than later. We've received a lot of feedback and worked really hard to find the best strategies and decisions for API, DX, architecture, etc., so we can confidently mark it as v1 and be sure we can improve it and remain flexible for all the features you are asking for, while becoming even better for everyone building on top of the drizzle API as well.

We didn't want to stay with some legacy decisions and solutions we had, and instead wanted to shape Drizzle in a way that will be best looking ahead to 2025–2026 trends (v1 will get proper effect support, etc.).

We believe that all of the effort we've put in will boost Drizzle and benefit everyone using it.

Thanks everyone, as we said, we are here to stay for a long time to build a great tool together!

Timelines

We are hoping to get v1 for drizzle in beta this fall and same timeline for latest. Right after that we can go through all of the issues and PRs and resond everyone. v1 for drizzle should close ~70% of all the bug tickets we have, so on beta release we will start marking them as closed!

AndriiSherman avatar Aug 30 '25 18:08 AndriiSherman

I am facing the same issue. The config is simple. I am using Neon database.

macOS m4 
node -v : 22
drizzle-kit: 0.31.x
drizzle-orm: 0.45

shriharip avatar Jan 09 '26 13:01 shriharip

I am facing the same issue. The config is simple. I am using Neon database.

macOS m4 
node -v : 22
drizzle-kit: 0.31.x
drizzle-orm: 0.45

Have you tried downgrading to version ^0.30.5?

sutejakw avatar Jan 09 '26 13:01 sutejakw

I am facing the same issue. The config is simple. I am using Neon database.

macOS m4 
node -v : 22
drizzle-kit: 0.31.x
drizzle-orm: 0.45

Have you tried downgrading to version ^0.30.5?

yes, it works on ^0.30.5

shriharip avatar Jan 09 '26 17:01 shriharip

I faced this same issue in 2026 with [email protected].

drizzle-kit migrate was hanging after:

Using 'pg' driver for database querying

No tables were created and no error was shown, which made debugging very difficult.

I initially thought the issue was caused by my configuration, Supabase setup, or migration SQL, and spent almost an entire day troubleshooting it.

Downgrading to:

"drizzle-kit": "^0.30.5"

fixed the issue immediately without changing anything else.

Environment:

  • Windows 11
  • PostgreSQL / Supabase
  • Node.js
  • drizzle-orm 0.45.x
  • drizzle-kit 0.31.x

Adding this comment in case it helps others facing the same problem.

Nirbhay21 avatar May 17 '26 02:05 Nirbhay21