porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.04k stars 257 forks source link

Migration script hangs after upgrading to postgres@3.4.4 #843

Closed adspacheco closed 3 months ago

adspacheco commented 3 months ago

After updating the postgres package from version 3.4.3 to 3.4.4 in my Bun project, I have encountered an issue where my migration script hangs indefinitely. The script works as expected without any problems when using version 3.4.3. However, after the upgrade, executing the migration script through Bun's CLI (bun migrate.ts) causes the terminal to freeze, and the process never completes.

Steps to Reproduce

  1. Upgrade the postgres package from 3.4.3 to 3.4.4 in a Bun project.
  2. Run the migration script using Bun's CLI command bun migrate.ts.

The migration script (migrate.ts) is as follows:

import postgres from "postgres";
import { drizzle } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator";

const connection = postgres('postgres://docker:docker@localhost:5432/db', { max: 1 });
const db = drizzle(connection);

await migrate(db, { migrationsFolder: 'drizzle' });

await connection.end();

console.log("closed connection");

process.exit();

Expected Behavior

The migration script should run to completion, applying the necessary database migrations, closing the connection, and then exiting the process, similar to how it behaves with version 3.4.3 of the postgres package.

Actual Behavior

Upon executing the migration script with postgres version 3.4.4, the terminal becomes unresponsive, and the script does not complete its execution. There is no error message and no console.log displays, and the process appears to be stuck indefinitely. )

Additional Context

Reverting back to version 3.4.3 of the postgres package resolves the issue, suggesting that the problem is likely introduced in 3.4.4.

Thank you!

porsager commented 3 months ago

If it works with node, the issue is in bun 😉

You can reopen if it also doesn't work in node, but it sounds like this issue here to me. https://github.com/porsager/postgres/issues/817#issuecomment-2030285794

You can simply use 3.4.3 until bun fixes it.