Not particularely. I use Cloud SQL for another project and it is quite nice, yeah.
Not particularely. I use Cloud SQL for another project and it is quite nice, yeah.
null and the pooler connection times out without ever connecting. Anyone know what might be going wrong?pnpm run devwrangler.tomlnpx wrangler hyperdrive create linkp-neon-hyperdrive --connection-string="🚧 Creating 'linkp-neon-hyperdrive'
✅ Created new Hyperdrive config
{
"id": "<ID>",
"name": "linkp-neon-hyperdrive",
"origin": {
"host": "ep-old-sky--pooler.ap-southeast-1.aws.neon.tech",
"port": 5432,
"database": "linkp-db",
"scheme": "postgresql",
"user": "hyperdrive-user"
},
"caching": {
"disabled": false
}
}src/index.tsexport const injectDB = createMiddleware(async (c, next) => {
try {
console.log(
Connecting to database...${c.env.HYPERDRIVE.connectionString}
);
const sql = neon(c.env.HYPERDRIVE.connectionString);
c.req.db = drizzle({ client: sql, schema });
await next();
} catch (error) {
console.error("Database connection error:", error);
throw new HTTPException(503, { message: "Database connection failed" });
}
});import { drizzle } from "drizzle-orm/neon-http";Postgres & node-postgres instead of neon-http
env.HYPERDRIVE.connectionString in the global context?wrangler dev) does not currently support connecting to remote databases that require SSL. It is a known gap that we are hoping to address in the future.docker run -d -e POSTGRES_PASSWORD=password -p 5433:5432 postgres:16 -c ssl=on -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key)wrangler dev --remote which spawns an ephemeral Worker and will behave like a normal Worker. Still wants a localConnectionString but will use the Hyperdrive binding you give it instead.sslmode=disable (this is probably the hardest to mange given I don't think Supabase supports that)env in the request, but in my project drizzle configuration is defined in a separate file:const db = createDrizzle(env.HYPERDRIVE_URL, env.SSL) where you need to use it.🚧 Creating 'linkp-neon-hyperdrive'
✅ Created new Hyperdrive config
{
"id": "<ID>",
"name": "linkp-neon-hyperdrive",
"origin": {
"host": "ep-old-sky--pooler.ap-southeast-1.aws.neon.tech",
"port": 5432,
"database": "linkp-db",
"scheme": "postgresql",
"user": "hyperdrive-user"
},
"caching": {
"disabled": false
}
}export const injectDB = createMiddleware(async (c, next) => {
try {
console.log(
);
const sql = neon(c.env.HYPERDRIVE.connectionString);
c.req.db = drizzle({ client: sql, schema });
await next();
} catch (error) {
console.error("Database connection error:", error);
throw new HTTPException(503, { message: "Database connection failed" });
}
});docker run -d -e POSTGRES_PASSWORD=password -p 5433:5432 postgres:16 -c ssl=on -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key[wrangler:inf] GET ... 500 Internal Server Error (30722ms)
Error: write CONNECT_TIMEOUT ...:5432
at RG (file:///Users//.wrangler/tmp/dev-pvRk1H/index.js:67:18734)
at n (file:///Users//.wrangler/tmp/dev-pvRk1H/index.js:78:3715)
at cachedError (file:///Users//.wrangler/tmp/dev-pvRk1H/index.js:67:6484)
at new Query (file:///Users//.wrangler/tmp/dev-pvRk1H/index.js:67:4794)
at Ve (file:///Users//.wrangler/tmp/dev-pvRk1H/index.js:88:1506)
at getTemplateRules (file:///Users//.wrangler/tmp/dev-pvRk1H/index.js:769:3897) {
code: CONNECT_TIMEOUT,
errno: CONNECT_TIMEOUT,
address: ...,
port: 5432,
stack: Error: write CONNECT_TIMEOUT .../.wrangler/tmp/dev-pvRk1H/index.js:769:3897)
...
}const client = postgres(process.env.db || DATABASE_URL, {
ssl: DATABASE_SSL === 'true',
prepare: false
});
export const db = drizzle(client, { schema });export const createDrizzle = (url: string, ssl: boolean) => {
const db = postgres(url, {
ssl
});
return drizzle(client, { schema });
};