N
Neon7mo ago
dependent-tan

Intermittent errors establishing h2 connection and setting up JWT authorization database extension

Hi, my team is building a NextJS 15 application using Drizzle ORM and Neon RLS Authorize, and we're running into the following two errors intermittently:
Error [NeonDbError]: Server error (HTTP status 500): could not establish h2 connection
Error [NeonDbError]: Server error (HTTP status 500): could not establish h2 connection
Error [NeonDbError]: Server error (HTTP status 500): could not set up the JWT authorization database extension
Error [NeonDbError]: Server error (HTTP status 500): could not set up the JWT authorization database extension
We haven't been able to trace specifically what the cause is and don't see any additional error logs. I've started to think maybe we just have something configured wrong, here's the code we're using to set up our connections:
import { drizzle } from "drizzle-orm/neon-http";
import { drizzle as neonDrizzle } from "drizzle-orm/neon-serverless";
import { neonConfig, Pool } from "@neondatabase/serverless";
import ws from "ws";

neonConfig.webSocketConstructor = ws;

// For supporting transactions
const getTransactionalDb = () => {
const pool = new Pool({
// postgresql://neondb_owner:***@ep-***-pooler.us-east-1.aws.neon.tech/neondb?sslmode=require
connectionString: process.env.DATABASE_URL!,
});
const neon = neonDrizzle(pool, { casing: "snake_case" });
return neon;
};

// For use with Drizzle Authorize RLS
const authDB = drizzle({
// postgresql://authenticated@ep-***-pooler.us-east-1.aws.neon.tech/neondb?sslmode=require
connection: process.env.DATABASE_AUTHENTICATED_URL!,
casing: "snake_case",
});

export { authDB, getTransactionalDb }
import { drizzle } from "drizzle-orm/neon-http";
import { drizzle as neonDrizzle } from "drizzle-orm/neon-serverless";
import { neonConfig, Pool } from "@neondatabase/serverless";
import ws from "ws";

neonConfig.webSocketConstructor = ws;

// For supporting transactions
const getTransactionalDb = () => {
const pool = new Pool({
// postgresql://neondb_owner:***@ep-***-pooler.us-east-1.aws.neon.tech/neondb?sslmode=require
connectionString: process.env.DATABASE_URL!,
});
const neon = neonDrizzle(pool, { casing: "snake_case" });
return neon;
};

// For use with Drizzle Authorize RLS
const authDB = drizzle({
// postgresql://authenticated@ep-***-pooler.us-east-1.aws.neon.tech/neondb?sslmode=require
connection: process.env.DATABASE_AUTHENTICATED_URL!,
casing: "snake_case",
});

export { authDB, getTransactionalDb }
Any advice on what could be causing these issues?
1 Reply
dependent-tan
dependent-tanOP7mo ago
Hi, wanted to check and see if there's any advice on how to address these issues, or more information that I can provide. Thanks!

Did you find this page helpful?