Skip to content

Fix writeRaw buffer view invalidation on WASM memory growth#68

Open
hobostay wants to merge 1 commit intovercel-labs:mainfrom
hobostay:fix/writeraw-buffer-invalidation
Open

Fix writeRaw buffer view invalidation on WASM memory growth#68
hobostay wants to merge 1 commit intovercel-labs:mainfrom
hobostay:fix/writeraw-buffer-invalidation

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 5, 2026

Summary

  • Fix writeRaw() in WasmBridge creating a single Uint8Array view before the write loop
  • If writeBytes() triggers WASM memory growth (buffer detaches), subsequent iterations of the loop would fail because the view references a detached ArrayBuffer
  • Create a fresh Uint8Array view in each loop iteration to handle potential memory growth

Root cause

WebAssembly.Memory.grow() detaches the old ArrayBuffer. The write loop reuses the same buf view across iterations, but writeBytes() can trigger memory growth internally.

Test plan

  • Run existing unit tests: pnpm test
  • Test writing large amounts of data that exceed the initial WASM memory size

🤖 Generated with Claude Code

writeRaw() created a single Uint8Array view of WASM memory before
the write loop. If writeBytes() triggers WASM memory growth, the
buffer detaches and subsequent iterations fail. Create a fresh view
in each loop iteration to handle memory growth correctly.

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

vercel Bot commented May 5, 2026

Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant