Skip to content
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

prisma compatibility #21

Open
pi0 opened this issue Mar 8, 2024 · 8 comments
Open

prisma compatibility #21

pi0 opened this issue Mar 8, 2024 · 8 comments

Comments

@pi0
Copy link
Member

pi0 commented Mar 8, 2024

Yhere are probably easier ways to include a repro, but I ran in to the same problem with Prismas new database adapters.

Here's a repro-link codesandbox.io.

If you try yourself with prisma, it does require you to have generated the prisma client before building:

node_modules/.bin/prisma generate

Originally posted by @Zn4rK in #19 (comment)

@Zn4rK
Copy link

Zn4rK commented Mar 8, 2024

FWIW;

That reproduction uses Prismas dev version 5.11.0-dev.5.

When patched with mukundshahs patch, it did build, but it did not work when previewed with Wrangler.

It looks like Prisma 5.11.0 will be released very soon, and should probably have a stabilised wasm path.

When I tried the latest version of 5.11.0 (5.11.0-dev.52), with the patch, I got the following error when building instead:

[nitro 11:29:45 AM]  ERROR  Error: Could not load /SOME_PATH/node_modules/.pnpm/@[email protected][email protected]/node_modules/.prisma/client/query_engine_bg.wasm?module (imported by node_modules/.pnpm/@[email protected][email protected]/node_modules/.prisma/client/wasm-edge-light-loader.js): ENOENT: no such file or directory, open '/SOME_PATH/node_modules/.pnpm/@[email protected][email protected]/node_modules/.prisma/client/query_engine_bg.wasm?module'

The path

/SOME_PATH/node_modules/.pnpm/@[email protected][email protected]/node_modules/.prisma/client/query_engine_bg.wasm

does exists. If I manually remove the querystring (?module), and apply the patch, it does work.

@Zn4rK
Copy link

Zn4rK commented Mar 8, 2024

The prisma team has some integration tests here that might be helpful: https://github.com/prisma/ecosystem-tests/tree/dev/driver-adapters-wasm

@pi0
Copy link
Member Author

pi0 commented Mar 8, 2024

Thanks for the updates and info dear @Zn4rK ❤️

@SevInf
Copy link

SevInf commented Mar 13, 2024

Hey everyone, Sehii from Prisma team here.
We would really like to support Nitro and Nuxt edge deployments and I did my own short investigation into the problem. You can find basic reporduction of the problem here.
Offending code seems to be here - it assumes that import modules are valid JS identifiers which is not what wasm-bindgen does by default - idetifier need to be escaped.

Hope it helps!

@pi0
Copy link
Member Author

pi0 commented Mar 13, 2024

Thanks for the pointer dear @SevInf. I'm going to work on prisma driver integration soon (congrats on last release!) and will investigate this one as well.

(mainly for here we need a minimal reproduction or regression test. if you are able to provide it before me feel free to directly make PR 👍🏼 )

@pi0
Copy link
Member Author

pi0 commented Mar 14, 2024

#24 landed with a relevant fix. Keeping this issue open until making sure prisma is fully supported.

@SevInf
Copy link

SevInf commented Mar 15, 2024

@pi0 thanks for the fix!
I've updated by reproduction to the latest unwasm version. Now we are getting different error:

[unwasm] Failed to parse WASM module wasm/query_engine_bg-5343c5664d9b411c.wasm: Error: [unwasm] Failed to parse wasm/query_engine_bg-5343c5664d9b411c.wasm: Error: Unexpected instruction: 0xc1
    at parseWasm (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:6479:11)
    at parse (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/plugin.mjs:195:22)
    at Object.transform (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/plugin.mjs:272:73)
    at /Users/serhii/projects/unwasm-bug/node_modules/rollup/dist/shared/rollup.js:998:40 {
  [cause]: CompileError2: Unexpected instruction: 0xc1
      at parseInstructionBlock (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5351:19)
      at parseInstructionBlock (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5424:13)
      at parseInstructionBlock (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5424:13)
      at parseInstructionBlock (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5424:13)
      at parseInstructionBlock (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5424:13)
      at parseInstructionBlock (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5424:13)
      at parseInstructionBlock (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5424:13)
      at parseInstructionBlock (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5424:13)
      at parseInstructionBlock (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5424:13)
      at parseCodeSection (file:///Users/serhii/projects/unwasm-bug/node_modules/unwasm/dist/tools.mjs:5328:11)

0xc1 is a valid wasm instruction, so It looks like @webassmpblyjs/parser is not up to date with a spec.

@pi0
Copy link
Member Author

pi0 commented Mar 15, 2024

yes i guess i need to patch it again 😅 In the meantime, you can use ?module as workaround it will skip parsing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants