prisma: Error: ENOENT: no such file or directory, open '/var/task/prisma/generated/auth/query_compiler_bg.wasm
Bug description
We have been using prisma for some time and are already aware how to get it working in aws lambda with the rust engine.
We are now attempting to use prisma within an aws lambda using the no rust engine new feature. https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/no-rust-engine
We get the following error:
{ “errorType”: “Runtime.UnhandledPromiseRejection”, “errorMessage”: “Error: ENOENT: no such file or directory, open ‘/var/task/prisma/generated/auth/query_compiler_bg.wasm’”, “reason”: { “errorType”: “Error”, “errorMessage”: “ENOENT: no such file or directory, open ‘/var/task/prisma/generated/auth/query_compiler_bg.wasm’”, “code”: “ENOENT”, “errno”: -2, “syscall”: “open”, “path”: “/var/task/prisma/generated/auth/query_compiler_bg.wasm”, “stack”: [ “Error: ENOENT: no such file or directory, open ‘/var/task/prisma/generated/auth/query_compiler_bg.wasm’”, " at Object.openSync (node:fs:596:3)“, " at Object.readFileSync (node:fs:464:35)”, " at Object.getQueryCompilerWasmModule (/var/task/index.js:55527:58)“, " at /var/task/index.js:53492:51”, " at async Object.loadQueryCompiler (/var/task/index.js:53496:14)“, " at async Ft.instantiateQueryCompiler (/var/task/index.js:53534:75)” ] }, “promise”: {}, “stack”: [ “Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, open ‘/var/task/prisma/generated/auth/query_compiler_bg.wasm’”, " at process.<anonymous> (file:///var/runtime/index.mjs:1294:17)“, " at process.emit (node:events:517:28)”, " at emit (node:internal/process/promises:149:20)“, " at processPromiseRejections (node:internal/process/promises:283:27)”, " at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"
auth.prisma
Severity
🚨 Critical: Data loss, app crash, security issue
Reproduction
.
Expected vs. Actual Behavior
Expect it not to error with “Runtime.UnhandledPromiseRejection”
Frequency
Consistently reproducible
Does this occur in development or production?
Only in production (e.g., query engine, generated client)
Is this a regression?
Workaround
Prisma Schema & Queries
generator client {
provider = "prisma-client-js"
output = "../generated/auth"
previewFeatures = ["multiSchema", "queryCompiler", "driverAdapters"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
schemas = ["auth"]
}
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient as PrismaAuthClient } from "./../../prisma/generated/auth/client"
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaAuthClient({ adapter })
export const auth = betterAuth({
database: prismaAdapter(prisma, { provider: "postgresql" }),
emailAndPassword: {
enabled: true,
},
socialProviders: {
google: {
clientId: "123",
clientSecret: "123"
},
},
});
Prisma Config
// Add your `prisma.config.ts`
Logs & Debug Info
// Debug logs here
Environment & Setup
- OS: AWS Lambda Node 22
- Database: PostgresSQL
- **Node.js version:**22
Prisma Version
Environment variables loaded from .env
prisma : 6.10.1
@prisma/client : 6.10.1
Computed binaryTarget : debian-openssl-1.1.x
Operating System : linux
Architecture : x64
Node.js : v20.14.0
TypeScript : 5.6.3
Query Engine (Node-API) : libquery-engine 9b628578b3b7cae625e8c927178f15a170e74a9c (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
PSL : @prisma/prisma-schema-wasm 6.10.1-1.9b628578b3b7cae625e8c927178f15a170e74a9c
Schema Engine : schema-engine-cli 9b628578b3b7cae625e8c927178f15a170e74a9c (at node_modules/@prisma/engines/schema-engine-debian-openssl-1.1.x)
Default Engines Hash : 9b628578b3b7cae625e8c927178f15a170e74a9c
Studio : 0.511.0
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 11
- Comments: 15
Commits related to this issue
- fix: revert adoption of prisma driverAdapters see: https://github.com/prisma/prisma/issues/27486 — committed to Huskydog9988/drop by Huskydog9988 a year ago
We’re having the same issue with our Next.js application hosted on Vercel. The build process completes successfully, but in run-time we’re getting the server-side error below.
We’ve tried moving the prisma client output folder into node_modules, or generating it locally and preventing it from being regenerated when building on Vercel. However, both attempts were not successful.
It appears that the query_compiler_bg.wasm file in the generated Prisma client should first be instantiated, otherwise it is not bundled in the deployed container. I assume on AWS Lambda there is a similar issue at play.
It would be great if this issue with the prisma generate script could be fixed, since we’re seeing huge improvements in the query speed with the new query compiler and would love to make this available to our clients!
How do you configure this if your database is a package in a monorepo?
ie: App lives in:
apps/apiPrisma package in
packages/databaseClient is generated underpackages/database/generated/prisma/clientDB is included via import { PrismaClient} from '@myorg/databsase`
For Vercel/NextJS users, if you are like me and want this to work instead of reverting changes you need to include prisma generated files in your output files.
Pay attention that I’m only including prisma on
"/api/**/*"because I access to my DB thought API’s.If you have server components or server actions my config won’t work.
Options:
space increase
After this change I notice my functions increased from
is there a solution for this?
i tried to deploy my app on vercel and i end up with the same error as:
Invalidprisma.project.findMany()invocation: ENOENT: no such file or directory, open '/var/task/prisma/generated/query_compiler_bg.wasm'