Prisma does not work with Cloudflare Workers (for me)
See original GitHub issueBug 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:
PrismaClient is unable to be run in the browser.
Datasource URL must use prisma:// protocol when --data-proxy is used
How to reproduce
- Clone this reproduction repo
- Run
yarn install
For normal (non-edge) version:
- Run
yarn generate:normal
- Run
yarn dev:normal
- Go to
localhost:8787
For edge version:
- Run
yarn generate:edge
- Run
yarn dev:edge
- Go to
localhost:8787
Expected behavior
- Should work locally without routing everything through the Data Proxy
- 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:
- Created a year ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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).
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.