Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v6.0.5 throws error when using native Bun SQL bindings #5964

Open
Philenst opened this issue Mar 17, 2025 · 2 comments · Fixed by oven-sh/bun#18478
Open

v6.0.5 throws error when using native Bun SQL bindings #5964

Philenst opened this issue Mar 17, 2025 · 2 comments · Fixed by oven-sh/bun#18478

Comments

@Philenst
Copy link

Philenst commented Mar 17, 2025

Apologies if this is in the wrong place, however I was not sure if I should have made this issue with Bun, require-in-the-middle, or PM2

Bun: 1.2.5
PM2: 6.0.5
OS: Ubuntu 24.04.2 LTS (GNU/Linux 6.8.0-55-generic x86_64)

Bun has a native PostgreSQL binding as documented here

With the below code, I can run it using "bun run" without any issues:

.env:

POSTGRES_URL = postgres://advance:advance@localhost:5432/advance

test-sql.ts

import { sql } from "bun";

console.log(await sql`SELECT version()`)

running:

bun run test-sql.ts

returns:

[
  {
    version: "PostgreSQL 16.8 (Ubuntu 16.8-0ubuntu0.24.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, 64-bit",
  },
  count: 1,
  command: "SELECT"
]

However when I try to run the same code via PM2, I get the below error:

 96 |     const isPatching = patching.has(filename)
 97 |     if (isPatching === false) {
 98 |       patching.add(filename)
 99 |     }
100 | 
101 |     const exports = self._origRequire.apply(this, arguments)
                                            ^
TypeError: require() async module "/home/lemres/badvance/test-sql.ts" is unsupported. use "await import()" instead.
      at <anonymous> (/home/lemres/.bun/install/global/node_modules/require-in-the-middle/index.js:101:39)
      at <anonymous> (/home/lemres/.bun/install/global/node_modules/pm2/lib/ProcessContainerForkBun.js:27:1)

I have tried to start with and without interpreter, however both unfortunately returned the same error.

pm2 start test-sql.ts --name test-sql --attach
pm2 start test-sql.ts --name test-sql --attach --interpreter bun

Please let me know if I'm searching in the wrong direction or if you require any further information.

@RolandasRazma
Copy link

RolandasRazma commented Mar 26, 2025

looks like it's bun oven-sh/bun#18478

@paperclover
Copy link

yes, this is a bug in bun that will be fixed in the linked PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants