Code Monkey home page Code Monkey logo

Comments (4)

max-petrenko avatar max-petrenko commented on July 19, 2024 1

Thanks for the prompt reply and sorry for me being a little sluggish with mine.

I believe I am not calling Prisma from the middleware or any other place that can potentially have the edge runtime turned on. This is my middleware.ts code (pretty much the only place something may break at) - it was configured with accordance to the Edge Compatibility page recommendations from NextAuth docs:

import { authConfig } from '@/config/auth/config'
import { DEFAULT_LOCALE, LOCALES, LOCALE_PREFIX_STRATEGY } from '@/config/intl'
import NextAuth from 'next-auth'
import createI18nMiddleware from 'next-intl/middleware'

const { auth } = NextAuth(authConfig)

const rerouteByLocale = createI18nMiddleware({
  locales: LOCALES,
  defaultLocale: DEFAULT_LOCALE,
  localePrefix: LOCALE_PREFIX_STRATEGY,
})

export const middleware = auth(request => rerouteByLocale(request))

export const config = {
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
}

Therefore, I believe it's actually the second option that is taking place, and I will try to provide a reproduction example ASAP

from prisma.

max-petrenko avatar max-petrenko commented on July 19, 2024

Getting the same error after trying to call $use instead in this fashion:

const getClient = () => {
  const client = new PrismaClient()
  client.$use(async (params, next) => {
    const before = Date.now()

    const result = await next(params)

    const after = Date.now()

    console.log(
      `Query ${params.model}.${params.action} with ${params.args} took ${after - before}ms`,
    )

    return result
  })
  return client
}

from prisma.

max-petrenko avatar max-petrenko commented on July 19, 2024

$extends call errors out as well

from prisma.

janpio avatar janpio commented on July 19, 2024

Where are you trying to use Prisma Client?

Next.js middleware for example is unfortunately always executed in the edge runtime of Vercel, even when running it locally via next dev or similar (see a massive discussion about this here: vercel/next.js#46722), which means you really have to follow these instructions to be able to talk to a database. In that case, this is not related to $on or $use at all and we unfortunately can't do much besides showing the instructions you are seeing.

If you are not trying to use it in middleware or anything similar that runs in the edge runtime, this is a false positive of our detection code. For that case, a reproduction repository with a minimal Next.js app and the absolutely needed code that is needed to trigger this situation would be the best way forward.

from prisma.

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.