You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside the browser run QuickJS sandbox, response.text() returns the body's bytes joined by commas instead of the decoded text. response.json() is therefore broken for every network response.
asynctext(): Promise<string>{constcontent=awaitthis.body();// a plain Uint8Array under QuickJS, not a Node Bufferreturncontent.toString('utf8');// Uint8Array.toString() ignores the argument}
Uint8Array.prototype.toString inherits Array.prototype.toString, which comma-joins the elements and discards the 'utf8' argument. There is no Node Buffer in the sandbox.
Knock-on effect
response.json() calls JSON.parse on that comma-joined string and fails with unexpected data at the end. normalizeExecutionError then matches /syntaxerror/i and reports it as BROWSER_RUN_SYNTAX_ERROR — telling the caller their program has a syntax error when it is valid JavaScript. Filed separately as #355.
Fix
The sandbox already injects a decoder for exactly this: decodeText in src/browser/run/playwright-client/quickjs-platform.ts, backed by __webcmdDecodeText in src/browser/run/runner.ts. this._platform is available on the class — see network.ts:393 for an existing use.
The vendored client is bundled into src/browser/run/generated/playwright-client.js, so the bundle needs regenerating (see src/browser/run/playwright-client/README.md), and src/browser/run/playwright-client-build.test.ts may need updating.
Worth a regression test asserting response.text() returns decoded text for a known body.
Impact
In the internal task eval this cost roughly five wasted attempts in one scenario: the agent tried response.json(), then JSON.parse on the raw value, then several exploratory scripts, before working out that it had to decode comma-separated byte values by hand.
Correction to the Fix section above: this._platform.decodeText(content) is wrong and would be undefined at runtime. decodeText lives on the exported quickjsEncoding object in src/browser/run/playwright-client/quickjs-platform.ts, not on the Platform type — vendor/protocol/validatorPrimitives.ts shows the correct import pattern.
Fixed in #357, which also caught Request.postData() carrying the identical toString('utf-8') defect.
Activity
ankitranjan7 commentedon Aug 19, 2026
Correction to the Fix section above:
this._platform.decodeText(content)is wrong and would beundefinedat runtime.decodeTextlives on the exportedquickjsEncodingobject insrc/browser/run/playwright-client/quickjs-platform.ts, not on thePlatformtype —vendor/protocol/validatorPrimitives.tsshows the correct import pattern.Fixed in #357, which also caught
Request.postData()carrying the identicaltoString('utf-8')defect.fix(browser): decode response bodies as UTF-8 text in the run sandbox (…