question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prisma does not work with Cloudflare Workers (for me)

See original GitHub issue

Bug description

I wanted to use Prisma with Cloudflare Workers so I followed the official guide in docs. Didn’t work (problems with env). Eventually I was able to resolve the issue after reading through issues here. But now Prisma shows ones of these errors:

  1. PrismaClient is unable to be run in the browser.
  2. Datasource URL must use prisma:// protocol when --data-proxy is used

How to reproduce

  1. Clone this reproduction repo
  2. Run yarn install

For normal (non-edge) version:

  1. Run yarn generate:normal
  2. Run yarn dev:normal
  3. Go to localhost:8787

For edge version:

  1. Run yarn generate:edge
  2. Run yarn dev:edge
  3. Go to localhost:8787

Expected behavior

  1. Should work locally without routing everything through the Data Proxy
  2. Should not see Cloudflare Workers as browser

Prisma information

Could be found inside the repo.

Environment & setup

  • OS: MacOS 12.6
  • Database: PostgreSQL
  • Node.js version: 18.7.0

Prisma Version

4.3.1

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
janpiocommented, Sep 20, 2022

We understand.

I’ll close this issue now, but please report back again if this does not (technically) work for you as I described. You can also leave a +1 on that feature request I linked to, or even share your use case (how you would want to set up your testing locally with wrangler vs. live).

0reactions
yamiterucommented, Sep 20, 2022

Ok so it’s exactly as I’ve feared. Well that sucks. Will try tomorrow and see how inconvenient it is. If it’s too inconvenient I’ll be forced in using a different setup not including Prisma which I don’t wanna do because I really like Prisma. But I need to start working on the project and can’t wait months for a better solution to be developed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma Edge Client + CF Worker process not defined #13771
Prisma Client must be created inside the handler and not on the module level. This is a Cloudflare limitation which we cannot work...
Read more >
Deploying to Cloudflare Workers - Prisma
With Cloudflare Workers, you can't directly access your database because there is no TCP support. Fortunately, Prisma has your back with the Data...
Read more >
Database Access on the Edge with Cloudflare Workers & Prisma
Node Congress 2022 #NodeCongress #Node #GitNationWebsite – https://nodecongress.com/Follow the link to watch the full version of all the ...
Read more >
Prisma's architecture seems novel and ... a little strange to me ...
AFAIK Cloudflare workers run JS/WASM in a V8 isolate, don't have Node.js APIs, and block eval()/new Function.
Read more >
marcomafessolli/remix-prisma-cloudflare-workers
Learn how to build and deploy a fullstack application using Remix, Prisma, and MongoDB. In this article, we will be setting up our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found