Closed ymc9 closed 6 months ago
I want to note that although I requested this feature, I have since moved away from using Prisma and, therefore, ZenStack in my edge runtime routes altogether. Prisma gets bloated very quickly, with all models included, so it is really easy to exceed the maximum bundle size (Hobby: 1 MB, Pro: 2 MB, Ent: 4 MB).
I want to note that although I requested this feature, I have since moved away from using Prisma and, therefore, ZenStack in my edge runtime routes altogether. Prisma gets bloated very quickly, with all models included, so it is really easy to exceed the maximum bundle size (Hobby: 1 MB, Pro: 2 MB, Ent: 4 MB).
Got it. May I know what your deployment target is? So it's still bloated even using the Edge version of PrismaClient, right? That's surprising ...
Yes, @prisma/client/runtime/edge.js
and .prisma/client/edge.js
are the two largest dependencies, and without them the bundle size goes from 2.84 MB down to 613 KB. I should also be able to remove the third largest dependency, which is zod/lib/types.js
.
Yes,
@prisma/client/runtime/edge.js
and.prisma/client/edge.js
are the two largest dependencies, and without them the bundle size goes from 2.84 MB down to 613 KB. I should also be able to remove the third largest dependency, which iszod/lib/types.js
.
OK, that's a surprise. Prisma team should look into it 🤷🏻. What's your alternative now? Drizzle?
I am saving the data from the client side and I am avoiding database access in the edge function. If I didn't have that option, I would try the new @prisma/adapter-planetscale or access the database through my REST or rRPC API.
Fixed in 2.0.0-beta.8 (for Vercel edge and Cloudflare worker)
was excited to hear this available for cloudflare
but disappointed D1 isn't supported (if it did zenstack would see massive adoption from our side)
what are my options here? put off by vercel as it is 10x more expensive than cloudflare. i like having database close to the users without having to setup read replicas :/
zenstack would be perfect if it could support D1 somehow
was excited to hear this available for cloudflare
but disappointed D1 isn't supported (if it did zenstack would see massive adoption from our side)
what are my options here? put off by vercel as it is 10x more expensive than cloudflare. i like having database close to the users without having to setup read replicas :/
zenstack would be perfect if it could support D1 somehow
Hi @crowd4gpt , the main obstacle for D1 support is its lack of interactive transactions. ZenStack uses ITX in certain cases to enforce access policies. I think it's possible to have partial support for D1 with some usage patterns of policy rules disallowed. A thorough review is needed to determine if it's viable.
Do you mind creating a separate FR for it?
Background
Prisma didn't support running in the edge environment (Vercel, CloudFlare, etc.) in older versions, so it wasn't a design goal for ZenStack either. However, things have been changing fast in the past few months:
Proposed Solution
The main obstacle to running ZenStack on the edge today is the environment doesn't allow dynamic
require
calls. ZenStack uses it to dynamically load generated code (for evaluating access policies) and determine Prisma version (for compatibility with both v4 and v5), and a few other less important occasions.However, if we go ahead and make the
enhance
API generated as well, the dynamicity mentioned above can be determined atzenstack generate
time instead of runtime. I believe it's doable but requires careful backward compatibility testing and verification in different edge environments.Question
What are the main edge runtime providers that people care about besides Vercel and CloudFlare?