feat(examples): add Prisma + Hyperdrive example#609
feat(examples): add Prisma + Hyperdrive example#609JamesbbBriz wants to merge 1 commit intocloudflare:mainfrom
Conversation
Full-stack CRUD example demonstrating: - Per-request PrismaClient (solves alternating connection failures on Workers) - Hyperdrive connection pooling via cloudflare:workers binding - Server component data fetching with Prisma - Route handler CRUD API using standard Web Request/Response
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0731fd6e29
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| */ | ||
|
|
||
| // @ts-expect-error -- virtual module resolved by vinext at build time | ||
| export { default } from "virtual:vinext-app-handler"; |
There was a problem hiding this comment.
Import the supported vinext app entry
virtual:vinext-app-handler is not a virtual module that vinext resolves, so this export will fail during bundling with an unresolved import and the example cannot build/deploy. In packages/vinext/src/index.ts, the resolver only handles IDs like virtual:vinext-rsc-entry, virtual:vinext-app-ssr-entry, and virtual:vinext-app-browser-entry (or the non-virtual vinext/server/app-router-entry).
Useful? React with 👍 / 👎.
| if (cached && now - cachedAt < 50) { | ||
| return cached; |
There was a problem hiding this comment.
Stop reusing Prisma client across requests
This time-based cache is not actually request-scoped: two different requests that arrive within 50ms (including concurrent requests in one Worker isolate) will receive the same PrismaClient. Since this example’s rationale is avoiding cross-request connection reuse, this condition can reintroduce the same class of failures under load and makes behavior nondeterministic by request timing.
Useful? React with 👍 / 👎.
Summary
Add a full-stack CRUD example demonstrating Prisma v7 with Hyperdrive on Cloudflare Workers. This is the first database example in the repo — fills a major gap for users migrating data-driven apps to vinext.
What it shows
cloudflare:workersbindingRequest/Response(notNextRequest)Structure
Key pattern: per-request client
This pattern is production-validated — we run it on Workers Free plan (10ms CPU limit) with zero alternating failures.
Blast radius
Zero — new directory only, no changes to existing code.
Relates to #537