Skip to content

Fix stale DataView after WASM memory growth#65

Open
hobostay wants to merge 1 commit into
vercel-labs:mainfrom
hobostay:fix/wasm-stale-dataview
Open

Fix stale DataView after WASM memory growth#65
hobostay wants to merge 1 commit into
vercel-labs:mainfrom
hobostay:fix/wasm-stale-dataview

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 5, 2026

Summary

  • Fix WasmBridge caching a DataView (_dv) that becomes invalid when WASM memory grows (buffer detaches)
  • getCell() and getScrollbackCell() now create a fresh DataView from this.memory.buffer on each call instead of using the cached reference
  • Prevents TypeError: Cannot perform DataView.prototype.getUint32 on a detached ArrayBuffer after memory growth

Root cause

WebAssembly.Memory.grow() creates a new ArrayBuffer and detaches the old one. The _dv was only refreshed in _updatePointers() (called from init() and resize()), but WASM memory can grow at any time during writeBytes().

Test plan

  • Run existing unit tests: pnpm test
  • Test with large terminal output that might trigger memory growth

🤖 Generated with Claude Code

The cached _dv DataView becomes invalid when WASM memory grows
(detached ArrayBuffer), causing TypeError on subsequent getCell()
and getScrollbackCell() calls. Create a fresh DataView from
this.memory.buffer on each access instead of caching it.

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