Comments (15)
Yes exactly, I was also surprised by the radio silence as it seems like a setup that is going to be prevalent (next edge, Vercel Postgres, drizzle).
Also asked in the next and drizzle discord help forums and again, silence in both. Pretty disappointing.
I’ll reopen the issue as I realise it’s not actually solved, I’ve just replaced vercel Postgres to get around it.
I’ll try and see if I can work out if the issue is vercel Postgres or drizzle pg to help narrow things down.
from storage.
Hey there, as far as @vercel/postgres
npm package goes, our latest release fixed this issue: https://github.com/vercel/storage/releases/tag/%40vercel%2Fpostgres%400.3.2
You only have to upgrade. If not just let us know in this thread 👍
from storage.
For anyone who finds this. I believe the issue is with the drizzle postgres plugin or the vercel storage driver.
I've switched to planetscale mysql, using drizzle and next edge functions and the issue doesn't repeat.
from storage.
I have the same issue using drizzle-orm and vercel postgres
I'm surprised this is not getting more attention
If you refresh a few times in quick succession edge function timeouts and the website is down
from storage.
I tried with neondatabase directly (what vercel uses under the hood) and the same issue occurs
However just like you I have no problem when switching to planetscale
Probably not a vercel issue in this case
from storage.
I was facing the same issue with neon.tech, which is what Vercel postgres is using. And I strongly believe that it's either caused by neondatabse driver or the neon services.
from storage.
i'm using nuxt with planetscale, vercel and got a server timeout. Probably cold start is too long??
from storage.
I think this particular issue is with neon (and by extension vercel storage).
Planetscale and drizzle using the planetscale js driver has been flawless for me so far.
from storage.
cold start + 10sec edge function timeout is lethal combination, this is asbolutely not reliable solution
from storage.
Hi to all of you in this thread, we've identified a problematic pattern of @vercel/postgres
that indeed generates timeout when deployed on Vercel Edge Functions.
While we dig this issue we advise you to switch from:
import { sql } from "@vercel/postgres";
const client = await sql.connect();
const result = await client.query('SELECT now()');
👆This is currently triggering timeouts on Edge Function, do not use it if you can avoid it.
to:
import { sql } from "@vercel/postgres";
const result = await sql`SELECT now()`;
// or const result = await sql.query('SELECT now()');
👆This works and doesn't trigger timeouts.
We understand that this is not ideal, especially because the drizzle-orm currently uses the problematic pattern.
We understand not everyone can switch to this pattern.
I tried with neondatabase directly (what vercel uses under the hood) and the same issue occurs However just like you I have no problem when switching to planetscale
Probably not a vercel issue in this case
Dear @chungweileong94 and @alexis-dorosz, if you were able to reproduce this issue directly on neon.tech, could you provide us with some code samples you used that reproduced the issue? Thanks.
from storage.
Hi to all of you in this thread, we've identified a problematic pattern of
@vercel/postgres
that indeed generates timeout when deployed on Vercel Edge Functions.While we dig this issue we advise you to switch from:
import { sql } from "@vercel/postgres"; const client = await sql.connect(); const result = await client.query('SELECT now()');👆This is currently triggering timeouts on Edge Function, do not use it if you can avoid it.
to:
import { sql } from "@vercel/postgres"; const result = await sql`SELECT now()`; // or const result = await sql.query('SELECT now()');👆This works and doesn't trigger timeouts.
We understand that this is not ideal, especially because the drizzle-orm currently uses the problematic pattern. We understand not everyone can switch to this pattern.
I tried with neondatabase directly (what vercel uses under the hood) and the same issue occurs However just like you I have no problem when switching to planetscale
Probably not a vercel issue in this caseDear @chungweileong94 and @alexis-dorosz, if you were able to reproduce this issue directly on neon.tech, could you provide us with some code samples you used that reproduced the issue? Thanks.
hi, is there any workaround for prisma?
from storage.
Hi @ghostneneji, can you give me pointers as for how you're using prisma + Vercel Postgres? Thanks
from storage.
@vvo I might not be able to create one at least for now, but I will try to create one once I'm able to.
However, I think I know what is the cause since now I look back. I was following the code snippet from drizzle doc, but without the ctx.waitUntil(pool.end())
, which will cause the edge runtime to timeout according to the neon-serverless driver doc, but I'm not really sure how I suppose to achieve the same thing in NextJS tho🤔
from storage.
Thank you for the update, good to know it’s resolved.
from storage.
Hi @ghostneneji, can you give me pointers as for how you're using prisma + Vercel Postgres? Thanks
hi, i'm using the prisma in standard way. I created a utility like this:
import { PrismaClient } from "database-streaming";
let prisma: PrismaClient;
if (process.env.NODE_ENV === "production") {
prisma = new PrismaClient();
} else {
if (!global.prisma) {
global.prisma = new PrismaClient();
}
prisma = global.prisma;
}
export default prisma;
then i use the prisma instance in the api call, for example:
import { withApiErrorHandler } from "../../../../utils/with-api-error-handler";
import { getSession, withApiAuthRequired } from "@auth0/nextjs-auth0";
import prisma from "../../../../utils/prisma";
export default withApiErrorHandler(
withApiAuthRequired(async (req, res) => {
if (req.method === "GET") {
const session = await getSession(req, res);
const user = await prisma.user.findUnique({
where: { auth0Id: session.user.sub },
});
res.status(200).json(user);
return;
}
res.status(403).json("Method not supported");
})
);
by adding pool_timeout=0
to the database url is helping a lot, but i still have high chance to run in timeout
from storage.
Related Issues (20)
- How to delete an entry in Vercel KV? HOT 2
- Add the ability to get the latest updatedAt first in the https://vercel.com/docs/storage/vercel-blob/using-blob-sdk#list method HOT 2
- Cannot delete blob database HOT 2
- Is there a way to change timezone for a session HOT 1
- Vercel Blob: Access denied, please provide a valid token for this resource HOT 15
- Progress rate of upload to Blob HOT 2
- Support for Signed URLs in Blob HOT 2
- Getting a broken image file from Blob storage HOT 2
- How to get the url by pathname? HOT 4
- Kysely Migrations fail because VercelPostgresDialect fails to report that VercelPostgres does not support transactions HOT 2
- Cannot use @vercel/blob in Edge runtime HOT 4
- Intermittent Request Failures with Vercel Postgres and Next.js HOT 6
- Vercel KV Request vs Storage Limit
- insert query are cached HOT 5
- @vercel/kv Inconsistent increment behavior in Server Action HOT 5
- @vercel/postgres: Extended constant is not working HOT 5
- [vercel/blob] file should use the true mime type when uploading the file HOT 3
- Vercel KV not reachable HOT 2
- @vercel/postgres parameters bind error HOT 1
- Vercel Postgres Polling & Revalidation on Focus HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from storage.