New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next.js app build fails when using Prisma with DB driver in Server Action #23600
Comments
The top-level await used by the wasm-loader seems to be causing problems. (Probably not officially supported yet: vercel/next.js#31054) prisma/packages/client/src/generation/generateClient.ts Lines 190 to 191 in 0c29ecf
I have not submitted a pull request because I cannot evaluate the impact of this fix, but the build will be succeed if I created the following patch for the Prisma client generator. diff --git a/generator-build/index.js b/generator-build/index.js
index c66a69ee7783e69352da18aa5f0ac2ee28bc76cd..68b6c11fd61a9c663bdf9aad5359d7a2a4c6a83c 100644
--- a/generator-build/index.js
+++ b/generator-build/index.js
@@ -16644,7 +16644,7 @@ function buildQueryEngineWasmModule(wasm, copyEngine, runtimeNameJs) {
return `config.engineWasm = {
getRuntime: () => require('./query_engine_bg.js'),
getQueryEngineWasmModule: async () => {
- return (await import('#wasm-engine-loader')).default
+ return (await (await import('#wasm-engine-loader')).default).default
}
}`;
}
@@ -18320,8 +18320,8 @@ async function buildClient({
if (generator.previewFeatures.includes("driverAdapters")) {
fileMap["default.js"] = await JS(trampolineTsClient);
fileMap["default.d.ts"] = await TS(trampolineTsClient);
- fileMap["wasm-worker-loader.js"] = `export default (await import('./query_engine_bg.wasm')).default`;
- fileMap["wasm-edge-light-loader.js"] = `export default (await import('./query_engine_bg.wasm?module')).default`;
+ fileMap["wasm-worker-loader.js"] = `export default import('./query_engine_bg.wasm')`;
+ fileMap["wasm-edge-light-loader.js"] = `export default import('./query_engine_bg.wasm?module')`;
pkgJson["browser"] = "default.js";
pkgJson["imports"] = {
// when `import('#wasm-engine-loader')` is called, it will be resolved to the correct file |
I believe I'm having the same issue when trying to run Prisma + Neon Serverless Driver from the edge runtime, I'm receiving the error:
And I think this post on Stackoverflow describes the same issue as well: https://stackoverflow.com/questions/78192413/next-js-application-with-prisma-orm-and-neon-datasource/78213174#78213174 |
Same issue here. |
I have the same issue as well. The proposed fix seems to work well. Can someone review and release this please? |
I've been receiving this as well, but only when the Edge runtime is enabled in Next. The fact that this works in the Nodejs runtime (for me), and that other "top level awaits" (unrelated to Prisma) also throw an error when used in the Edge runtime suggests that this is a Next.js issue, rather than a Prisma one? (although if the patch works, it'd be great to get it in in the meantime) Edit Can confirm the patch works for me too, and I opened an Issue in Next.js too vercel/next.js#64792 |
We are having the same issue using generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
} const neon = new Pool({ connectionString: process.env["DATABASE_URL"] });
const adapter = new PrismaNeon(neon);
const prisma = new PrismaClient({ adapter }); When attempting to access the DB from
|
Hello, I'm also having this problem since I updated from Next 14.1.4 to 14.2.1. My setup is pretty similar to @DannyNemer . The problem only appears in Edge runtime. |
There's a PR to fix this: #23754 You can resolve it for now by patching |
Bug description
When building a Next.js application using Prisma on the edge runtime with the Database driver, the build fails with the following error. This problem seems to occur when using Prisma client on the server action imported by the client component. Also, this problem did not occur with Prisma v5.10.2 (in Early Access), and occurred with v5.11.0.
How to reproduce
git clone https://github.com/nzws/prisma-with-nextjs-edge-import-problem-repro
cd prisma-with-nextjs-edge-import-problem-repro
yarn install
yarn build
Expected behavior
The build passes normally and the application can run.
Prisma information
I created a repository that can reproduce this issue: https://github.com/nzws/prisma-with-nextjs-edge-import-problem-repro (nzws/prisma-with-nextjs-edge-import-problem-repro@cc513a7)
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: