Can't seem to use Postgres with drizzle in edge function
Answered
Serengeti posted this in #help-forum
SerengetiOP
I can't seem to use postgres with drizzle because of the following error:
Could anyone help me out with this?
- error ../node_modules/postgres/src/connection.js (131:10) @ net
- error net__WEBPACK_IMPORTED_MODULE_0__.Socket is not a functionimport { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
const client = postgres(process.env["DB_URL"] as string);
const db = drizzle(client);
export default db;Could anyone help me out with this?
37 Replies
SerengetiOP
It works when I use @vercel/postgres instead, but I have to use an AWS RDS instance and can't seem to get that working with vercel postgres
Oriental
Might need a bit more info. Is this edge or serverless?
SerengetiOP
edge
American Sable
This makes sense. You can't open up a regular DB connection on an edge function
SerengetiOP
ah ok
American Sable
You'd need work over http for DB communication. vercel's driver does that, which is why it works on the edge
SerengetiOP
how should i go about doing this?
American Sable
I mean, it depends on if the DB supports it
if you're using RDS, I'm unsure if theres a driver that will work with that
Vercel's works because it just uses Neon, which lets you query over regular http requests
Similar story with Planetscale on the MySQL side of things
SerengetiOP
let me try rds serverless
ill let you know if it works
SerengetiOP
on a side note, does anyone know how to make use of the new serverless function timeout extension (5 mins) within a nx project
SerengetiOP
can't seem to get it to work - probably because of the port somehow becoming 443
@Serengeti on a side note, does anyone know how to make use of the new serverless function timeout extension (5 mins) within a nx project
Within next project? I dont know how well that would work when you deploy it because vercel only allows like 5s before the function times out (atleast on free tier)
IIRC and im not confusing things ^
SerengetiOP
im on pro
@Serengeti im on pro
the announcement shows the export variable
@DirtyCajunRice | AppDir the announcement shows the export variable
SerengetiOP
yes, but it doesn't work for me, i'm still stuck at 1 minute
@Serengeti yes, but it doesn't work for me, i'm still stuck at 1 minute
How have you come to that conclusion? Show the variable you have exported, and the next error log after you updated that page in production
SerengetiOP
okay give me a sec
SerengetiOP
@Serengeti Click to see attachment
pretty sure its app dir only.
Answer
SerengetiOP
what do you mean by that? sorry im not super familiar with nextjs
@Serengeti what do you mean by that? sorry im not super familiar with nextjs
he means that [
export maxDuration](https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#maxduration), is only a thing for app dir... you can still use the [vercel.json](https://vercel.com/docs/projects/project-configuration#value-definition) file thoughSerengetiOP
ah okay
i tried using vercel.json but it also didn’t work
not sure if i’m configuring it wrongly because nx is confusing
Leafcutting bee
same issue here... any luck?
@Leafcutting bee same issue here... any luck?
he was trying to use an app dir feature in pages dir.
@DirtyCajunRice | AppDir he was trying to use an app dir feature in pages dir.
Leafcutting bee
I saw that. Adding
export maxDuration is only for app dir, but he also had maxDuration set inside his vercel.json. ( I do too ), but it does not work.Leafcutting bee
thanks.