prisma: [6.6] WebAssembly.instantiate(): Import #0 "./query_compiler_bg.js": module is not an object or function]
Bug description
Nitro + Prisma 6.6.0 + D1 does not work
Severity
๐จ Critical: Data loss, app crash, security issue
Reproduction
https://github.com/medz/nitro-prisma-6.6
Expected vs. Actual Behavior
Expected behavior: WASM modules can be parsed normally
Frequency
Consistently reproducible
Does this occur in development or production?
Only in development (e.g., CLI tools, migrations, Prisma Studio)
Is this a regression?
Prisma: 6.6.0 Nitro: 2.11.9 wrangler: 4.10.0
Workaround
Prisma Schema & Queries
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client"
output = "./client/"
previewFeatures = ["driverAdapters"]
runtime = "cloudflare"
}
model Result {
id String @id @default(uuid(7))
createdAt DateTime @default(now())
}
import { PrismaD1 } from "@prisma/adapter-d1";
import { PrismaClient } from "~/prisma/client";
export default defineEventHandler((event) => {
const adapter = new PrismaD1(event.context.cloudflare.env.DB as any);
const client = new PrismaClient({ adapter });
});
Logs & Debug Info
$ nitro dev
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ ๐ฅ Cloudflare context bindings enabled for dev server โ
โ โ
โ Config path: wrangler.toml โ
โ Persist dir: .wrangler/state/v3 โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โ Local: http://localhost:3000/
โ Network: use --host to expose
[unwasm] Failed to parse WASM module wasm/query_compiler_bg.sqlite-afbae85635953d66.wasm: Error: [unwasm] Failed to parse wasm/query_compiler_bg.sqlite-afbae85635953d66.wasm: Error: Internal failure: parseVec could not cast the value
at parseWasm (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/tools.mjs:6496:11)
at parse (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/plugin.mjs:195:22)
at Object.transform (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/plugin.mjs:272:73)
at file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/rollup/dist/es/shared/node-entry.js:22156:40 {
[cause]: CompileError2: Internal failure: parseVec could not cast the value
at parseVec (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/tools.mjs:5132:19)
at parseTypeSection (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/tools.mjs:5148:33)
at parseSection (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/tools.mjs:5895:26)
at Object.decode2 [as decode] (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/tools.mjs:6169:29)
at decode2 (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/tools.mjs:6476:25)
at parseWasm (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/tools.mjs:6494:11)
at parse (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/plugin.mjs:195:22)
at Object.transform (file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/unwasm/dist/plugin.mjs:272:73)
at file:///Users/seven/workspace/panews-api-server/test-prisma/node_modules/rollup/dist/es/shared/node-entry.js:22156:40
}
โ Nitro Server built in 1024ms nitro 10:46:54
[uncaughtException] [TypeError: WebAssembly.instantiate(): Import #0 "./query_compiler_bg.js": module is not an object or function]
Environment & Setup
- OS:
- Database:
- Node.js version:
Prisma Version
Prisma schema loaded from prisma/schema.prisma
prisma : 6.6.0
@prisma/client : 6.6.0
Computed binaryTarget : darwin-arm64
Operating System : darwin
Architecture : arm64
Node.js : v23.9.0
TypeScript : 5.8.2
Query Engine (Node-API) : libquery-engine f676762280b54cd07c770017ed3711ddde35f37a (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine : schema-engine-cli f676762280b54cd07c770017ed3711ddde35f37a (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm : @prisma/prisma-schema-wasm 6.6.0-53.f676762280b54cd07c770017ed3711ddde35f37a
Default Engines Hash : f676762280b54cd07c770017ed3711ddde35f37a
Studio : 0.511.0
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 6
- Comments: 32 (8 by maintainers)
+1 Same issue here
Running NextJS 15@canary with
nodeMiddleware: trueI just have encounterd this problem. since once updgraded to v6.6 from v6.5, even if v6.5 re-install, application keep crashโฆ
my environment is cloudflare pages and uses cloudflare-next-on-pagesโฆ
I was able to reproduce the error based on the reproduction repository:
Interestingly, when I tried downgrading to version 6.5.0, I got this error as well:
This is not necessarily needed. Hereโs another example using Turborepo where the package containing Prisma definitions isnโt built. The trick is to use
exportsmap: https://github.com/prisma/prisma-examples/blob/79440c034c91d6614c4849c8cedfede4a1cb7902/generator-prisma-client/nextjs-starter-webpack-turborepo/packages/database/package.json#L5-L8@jkomyno Really appreciate you looking into this. This is working now ๐
For anyone else experiencing this:
vite-tsconfig-pathsfrom my Vite configprovider = "prisma-client"prisma-clientSo far so good. Thank you!
Question based on the monorepo example: Is there an expectation that youโd need to build your prisma package before importing? Iirc, the other guides demonstrate being able to import without a build step in
/package/prismaI updated my prisma configuration to match the monorepo example but Im still seeing this error:
Fwiw. I am using Turborepo and Vite. Not sure to what extent those would affect the output.
@jacek-prisma We are happy to announce that this issue has been resolved. My configuration:
However, there is still a problem with
prisma-client. PrismaClient does not support theadapterparameter, but this does not affect the use of the function.It is worth noting that the package size of the same code once reached
3033.04 KiB / gzip: 1054.53 KiB, but now it is only2273.59 KiB / gzip: 803.94 KiB, which is a very big improvement.๐@aqrln
No, I tried again the other day to upgrade to Prisma 6.6.0 and continued to use the
prisma-client-jsgenerator.Everything works fine now.