Running queries to a Neon db from a worker stopped working after upgrading to wrangler 3.82.0
A ws proxy is sitting in front of neon db, which forwards the requests to the underlying postgres db.
Expected behavior
Before upgrading to 3.82.0 (with 3.81.0), there were no issues.
Steps to reproduce
Below is a minimum reproducible example, with a docker-compose to setup an emulated neondb locally with 1 table to test.
npm create cloudflare@latest
wrangler.toml
#:schema node_modules/wrangler/config-schema.json
name = "blue-wave-e62a"
main = "src/index.ts"
compatibility_date = "2024-10-11"
compatibility_flags = ["nodejs_compat"]
src/index.ts
import { neonConfig, Pool } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-serverless";
import * as schema from "./schema";
export default {
async fetch(request, env, ctx): Promise<Response> {
console.log("before");
await getDb().query.test.findFirst();
console.log("after"); // hangs, never gets here
return new Response('Hello World!');
},
} satisfies ExportedHandler<Env>;
function getDb() {
const dbClient = new Pool({ connectionString: "postgres://testdb:testdb@localhost:5442/testdb" });
// necessary to make neon work locally, used to work fine.
neonConfig.wsProxy = () => "127.0.0.1:5443/v1";
neonConfig.useSecureWebSocket = false;
neonConfig.pipelineTLS = false;
neonConfig.pipelineConnect = false;
return drizzle(dbClient, { schema, logger: true });
}
src/schema.ts
import { pgTable, text } from "drizzle-orm/pg-core";
export const test = pgTable("test", {
name: text("name").notNull(),
});
Which Cloudflare product(s) does this pertain to?
Wrangler
What version(s) of the tool(s) are you using?
wranger: 3.82.0, @neondatabase/serverless: ^0.10.1
What version of Node are you using?
20.18.0
What operating system and version are you using?
Win 11
Describe the Bug
Observed behavior
Running queries to a Neon db from a worker stopped working after upgrading to wrangler 3.82.0 A ws proxy is sitting in front of neon db, which forwards the requests to the underlying postgres db.
Expected behavior
Before upgrading to 3.82.0 (with 3.81.0), there were no issues.
Steps to reproduce
Below is a minimum reproducible example, with a docker-compose to setup an emulated neondb locally with 1 table to test.
npm create cloudflare@latest
wrangler.toml
src/index.ts
src/schema.ts
package.json
docker-compose.yml
dump.sql
run
docker-compose up -d
runnpm run dev
in another terminal runcurl localhost:8787
it hangsnow try either
compatibility_flags = ["nodejs_compat"]
from wrangler.toml3.81.0
vianpm install wrangler@3.81.0
it works .. unfortunatelly removing
nodejs_compat
is not an optionPlease provide a link to a minimal reproduction
No response
Please provide any relevant error logs
when running with log-level debug
npm run dev -- --log-level debug
I get this when it hangs:I get exactly the same when i downgrade or remove
nodejs_compat
just until the point it used to hang.