-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.domain/clientIssue in the "Client" domain: Prisma Client, Prisma Studio etc.Issue in the "Client" domain: Prisma Client, Prisma Studio etc.kind/bugA reported bug.A reported bug.topic: ENOENT schema.prismaIssues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'"Issues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'"topic: Next.jstopic: deployment/verceltopic: not-monorepotopic: prisma-client
Description
Bug description
When deploying a Next.js 13 (with app dir) on Vercel, I'm seeing the following error:
Error: ENOENT: no such file or directory, open '/var/task/.next/server/chunks/schema.prisma'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at new LibraryEngine (/var/task/.next/server/chunks/538.js:28292:45)
at PrismaClient.getEngine (/var/task/.next/server/chunks/538.js:32706:24)
at new PrismaClient (/var/task/.next/server/chunks/538.js:32678:37)
at Object.4963 (/var/task/.next/server/app/page.js:374:14)
at __webpack_require__ (/var/task/.next/server/webpack-runtime.js:25:42)
at page (/var/task/.next/server/app/page.js:237:87)
at createComponentTree (/var/task/node_modules/next/dist/server/app-render.js:578:80)
at /var/task/node_modules/next/dist/server/app-render.js:663:62 {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/var/task/.next/server/chunks/schema.prisma',
clientVersion: '4.5.0',
page: '/'
}
RequestId: 9ce84669-6d69-44b5-a6fc-f6e572a6a845 Error: Runtime exited with error: exit status 1
Runtime.ExitError
I've tried a few apps to try and reproduce this and this only happens when you make the page dynamic.
A few ways I've been able to reproduce this:
- Using the
export const revalidate = 0
segment config on a page - Calling
headers()
from "next/headers" inside the page.
✅ This works:
import { db } from "@/lib/db"
export default async function Page() {
const messages = await db.message.findMany()
return ...
}
❌ This does not work:
import { db } from "@/lib/db"
export const revalidate = 0 // 👈 Adding this results in the error above.
export default async function Page() {
const messages = await db.message.findMany()
return ...
}
❌ This does not work:
import { headers } from "next/headers"
import { db } from "@/lib/db"
export default async function Page() {
headers() // 👈 Adding this results in the error above.
const messages = await db.message.findMany()
return ...
}
How to reproduce
I have a sample app here: https://github.com/shadcn/next-prisma-app
- Create a new Next.js 13 app with a prisma model.
- Create a new file at
app/page.tsx
and try calling prisma there. - Add
export const revalidate = 0
- Deploy to Vercel and try accessing the page at
/
- You should the error above.
- Remove the export and try again.
- Error should be gone.
Expected behavior
Expected prisma to work with the segment config.
Prisma information
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
model Message {
id Int @id @default(autoincrement())
content String?
}
Environment & setup
- OS: Vercel (works fine locally on MacOS)
- Database: MySQL
- Node.js version: 16
Prisma Version
prisma : 4.5.0
@prisma/client : 4.5.0
Current platform : darwin
Query Engine (Node-API) : libquery-engine 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Format Wasm : @prisma/prisma-fmt-wasm 4.5.0-43.0362da9eebca54d94c8ef5edd3b2e90af99ba452
Default Engines Hash : 0362da9eebca54d94c8ef5edd3b2e90af99ba452
Studio : 0.476.0
Preview Features : referentialIntegrity
transitive-bullshit and JBartscher
Metadata
Metadata
Assignees
Labels
bug/2-confirmedBug has been reproduced and confirmed.Bug has been reproduced and confirmed.domain/clientIssue in the "Client" domain: Prisma Client, Prisma Studio etc.Issue in the "Client" domain: Prisma Client, Prisma Studio etc.kind/bugA reported bug.A reported bug.topic: ENOENT schema.prismaIssues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'"Issues about "Error: ENOENT: no such file or directory, open '.../schema.prisma'"topic: Next.jstopic: deployment/verceltopic: not-monorepotopic: prisma-client