Skip to content

fix: drop streaming wasm calls in Turbopack runtime#1244

Open
tahmid-23 wants to merge 2 commits intoopennextjs:mainfrom
tahmid-23:tahmid-23/turbopack-wasm-streaming
Open

fix: drop streaming wasm calls in Turbopack runtime#1244
tahmid-23 wants to merge 2 commits intoopennextjs:mainfrom
tahmid-23:tahmid-23/turbopack-wasm-streaming

Conversation

@tahmid-23
Copy link
Copy Markdown

@tahmid-23 tahmid-23 commented May 1, 2026

Turbopack replaces wasm imports using WebAssembly.compileStreaming and WebAssembly.instantiateStreaming. These functions are not available in the workerd runtime.

We add a helper loadWasmChunkFn. This is a generated switch statement that contains an import for each wasm chunk. We use static strings for all imports to ensure that all necessary wasm chunks will be detected and bundled for the final build.

The Turbopack patcher replaces the invocations in loadWebAssembly and loadWebAssemblyModule, using the synchronous WebAssembly.instantiate and redirecting to loadWasmChunkFn.

This fixes #1191, since Prisma 7 uses wasm.

I verified by applying (a slightly simplified version of) this patch to fix the error for myself. I also asked claude to verify that WebAssembly.compileStreaming / WebAssembly.instantiateStreaming were replaced in the final output, and that the switch case is generated.


Open in Devin Review

Turbopack replaces wasm imports using `WebAssembly.compileStreaming` and
`WebAssembly.instantiateStreaming`. These functions are not available in
the workerd runtime.

We add a helper `loadWasmChunkFn`. This is a generated switch statement
that contains an import for each wasm chunk. We use static strings for
all imports to ensure that all necessary wasm chunks will be detected
and bundled for the final build.

The Turbopack patcher replaces the invocations in `loadWebAssembly` and
`loadWebAssemblyModule`, using the synchronous `WebAssembly.instantiate`
and redirecting to `loadWasmChunkFn`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

🦋 Changeset detected

Latest commit: 31b50a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 1, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@1244

commit: ed60ff0

@vicb
Copy link
Copy Markdown
Contributor

vicb commented May 3, 2026

Thanks for the PR!

This fixes #1191, since Prisma 7 uses wasm.

Could you please add an e2e test for that?

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@tahmid-23
Copy link
Copy Markdown
Author

cc @vicb done (relying on ai having set up the test itself correctly but it seems to pass with the change and fail without)

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

Successfully merging this pull request may close these issues.

[BUG] Prisma 7 fails on opennextjs-cloudflare preview

2 participants