GithubHelp home page GithubHelp logo

Comments (15)

Xexr avatar Xexr commented on May 18, 2024 2

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.

vvo avatar vvo commented on May 18, 2024 2

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.

Xexr avatar Xexr commented on May 18, 2024

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.

alexis-dorosz avatar alexis-dorosz commented on May 18, 2024

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.

alexis-dorosz avatar alexis-dorosz commented on May 18, 2024

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.

chungweileong94 avatar chungweileong94 commented on May 18, 2024

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.

markjkaem avatar markjkaem commented on May 18, 2024

i'm using nuxt with planetscale, vercel and got a server timeout. Probably cold start is too long??

from storage.

Xexr avatar Xexr commented on May 18, 2024

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.

ghostneneji avatar ghostneneji commented on May 18, 2024

cold start + 10sec edge function timeout is lethal combination, this is asbolutely not reliable solution

from storage.

vvo avatar vvo commented on May 18, 2024

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.

ghostneneji avatar ghostneneji commented on May 18, 2024

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.

hi, is there any workaround for prisma?

from storage.

vvo avatar vvo commented on May 18, 2024

Hi @ghostneneji, can you give me pointers as for how you're using prisma + Vercel Postgres? Thanks

from storage.

chungweileong94 avatar chungweileong94 commented on May 18, 2024

@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.

Xexr avatar Xexr commented on May 18, 2024

Thank you for the update, good to know it’s resolved.

from storage.

ghostneneji avatar ghostneneji commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.