Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Proxy Client stopped working in Vercel Edge Functions / Next 12.0.4 #10305

Closed
millsp opened this issue Nov 16, 2021 · 3 comments
Closed
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: data proxy topic: deployment/vercel topic: Next.js
Milestone

Comments

@millsp
Copy link
Member

millsp commented Nov 16, 2021

New problem with Vercel Edge and the Data Proxy Client on next 12.0.4 and up

    A server error has occurred
    
    EDGE_FUNCTION_INVOCATION_FAILED
  • They now disable the usage of eval by doing an analysis of its usage
  • They say that they tree-shake this out instead, whenever it's possible
    • If not, they just error - they don't care for runtime logic.
  • We need this to have a a single build that works on Workers & Node.js
  • We eval('require...') Node.js deps to hide them away from bundlers
    • eg. fetch is used on Workers, but eval('require("http")') in Node

https://prisma-company.slack.com/archives/C016KUHB1R6/p1637100669072700

We need:

  • To have a pass on the evals that are bundled
  • Have a new import like @prisma/client/edge
  • That would add another runtime build
@millsp millsp self-assigned this Nov 16, 2021
@millsp millsp added this to the 3.6.0 milestone Nov 16, 2021
@millsp millsp added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: data proxy topic: deployment/vercel labels Nov 16, 2021
@janpio janpio removed the kind/bug A reported bug. label Nov 19, 2021
@Jolg42
Copy link
Member

Jolg42 commented Feb 1, 2022

Note that next version is currently "next": "12.0.10"
https://github.com/prisma/e2e-tests/blob/dev/workers/vercel-edge-functions/package.json#L12

And tests are passing.

See merged Renovate PRs
prisma/ecosystem-tests#2366
prisma/ecosystem-tests#2375
prisma/ecosystem-tests#2380

The last failing one was 12.0.5
prisma/ecosystem-tests#2357

So it works with a version between 12.0.5 and 12.0.9 or since 12.0.9 (unsure since renovate only tried to update .9, might be that it was working with a version in between)

@Jolg42
Copy link
Member

Jolg42 commented Apr 13, 2022

Using recent versions of Next with Vercel Edge Functions fails with

./node_modules/@prisma/client/runtime/proxy.js

Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Middleware pages/_middleware

The last working version is 12.0.10 from Feb 01, 2022
prisma/ecosystem-tests#2612 (comment)

@matthewmueller matthewmueller removed this from the 3.6.0 milestone Apr 22, 2022
@millsp millsp added this to the 3.15.0 milestone Jun 7, 2022
@millsp millsp closed this as completed Jun 7, 2022
@millsp
Copy link
Member Author

millsp commented Jun 7, 2022

Note for users finding this:

We have released some changes a few minutes ago in prisma@3.15.0. tl;dr;

  • Instead of PRISMA_CLIENT_ENGINE_TYPE, use prisma generate --data-proxy to enable the Data Proxy
  • import { PrismaClient } from '@prisma/client/edge' for a Vercel Edge Function compatible Prisma Client
  • Please be aware that .env aren't bundled into the generated Prisma Client any longer (see docs)
  • You can also remove any package location aliasing from your build scripts
  • Warnings around eval are now also fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: data proxy topic: deployment/vercel topic: Next.js
Projects
None yet
Development

No branches or pull requests

4 participants