From 4541a1bc1eaeef7cffcb1ad980e0cab2a397a4f1 Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 5 May 2026 08:46:31 +0800 Subject: [PATCH] Fix writeRaw buffer view invalidation in WasmBridge 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 --- packages/@wterm/core/src/wasm-bridge.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@wterm/core/src/wasm-bridge.ts b/packages/@wterm/core/src/wasm-bridge.ts index 981c300..885a0aa 100644 --- a/packages/@wterm/core/src/wasm-bridge.ts +++ b/packages/@wterm/core/src/wasm-bridge.ts @@ -102,10 +102,10 @@ export class WasmBridge implements TerminalCore { } writeRaw(data: Uint8Array): void { - const buf = new Uint8Array(this.memory.buffer, this.writeBufferPtr, 8192); let offset = 0; while (offset < data.length) { const chunk = Math.min(data.length - offset, 8192); + const buf = new Uint8Array(this.memory.buffer, this.writeBufferPtr, 8192); buf.set(data.subarray(offset, offset + chunk)); this.exports.writeBytes(chunk); offset += chunk;