Describe the bug
TextEncoder.prototype.encodeInto('') returns the result of the previous encodeInto call, from any encoder instance, instead of { read: 0, written: 0 }. Nothing is written to the destination, but callers that trust written read stale bytes.
We hit it through Yuku's WebAssembly parser (@yuku-core/wasm), which TanStack Router/Start is moving to: parsing an empty string parses leftover bytes, so Start server functions fail in WebContainers.
Link to the blitz that caused the error
https://stackblitz.com/github/Sheraff/webcontainer-encodeinto-repro
Steps to reproduce
Open the project. It runs npm start (index.js):
const a = new TextEncoder()
const b = new TextEncoder()
a.encodeInto('abc', new Uint8Array(9)) // { read: 3, written: 3 }
a.encodeInto('', new Uint8Array(4)) // { read: 3, written: 3 }
b.encodeInto('', new Uint8Array(4)) // { read: 3, written: 3 }
and prints BUG: encodeInto("") returns the previous call's { read, written } (WebContainer, Node v22.22.3).
Expected behavior
Both empty calls return { read: 0, written: 0 }, as in Node (v22.12.0, v24.8.0), where the project prints OK.
Parity with Local
Platform
- OS: Linux
- Browser: Chromium (Playwright)
- WebContainer:
process.versions.webcontainer = 2ed8f36d
Additional context
Found while testing TanStack Router's Yuku migration in the tanstack.com example playground. Written with Claude Code (AI-assisted).
Describe the bug
TextEncoder.prototype.encodeInto('')returns the result of the previousencodeIntocall, from any encoder instance, instead of{ read: 0, written: 0 }. Nothing is written to the destination, but callers that trustwrittenread stale bytes.We hit it through Yuku's WebAssembly parser (
@yuku-core/wasm), which TanStack Router/Start is moving to: parsing an empty string parses leftover bytes, so Start server functions fail in WebContainers.Link to the blitz that caused the error
https://stackblitz.com/github/Sheraff/webcontainer-encodeinto-repro
Steps to reproduce
Open the project. It runs
npm start(index.js):and prints
BUG: encodeInto("") returns the previous call's { read, written }(WebContainer, Node v22.22.3).Expected behavior
Both empty calls return
{ read: 0, written: 0 }, as in Node (v22.12.0, v24.8.0), where the project printsOK.Parity with Local
Platform
process.versions.webcontainer=2ed8f36dAdditional context
Found while testing TanStack Router's Yuku migration in the tanstack.com example playground. Written with Claude Code (AI-assisted).