Skip to content

fix(wasm-visor): read Uint8Array/ArrayBuffer request bodies (POSTs were corrupted to "<object>") - #3935

Open
0pcom wants to merge 2 commits into
skycoin:developfrom
0pcom:fix/wasm-fetch-body-uint8array
Open

fix(wasm-visor): read Uint8Array/ArrayBuffer request bodies (POSTs were corrupted to "<object>")#3935
0pcom wants to merge 2 commits into
skycoin:developfrom
0pcom:fix/wasm-fetch-body-uint8array

Conversation

@0pcom

@0pcom 0pcom commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Bug

Every POST/PUT issued from the in-tab wasm-visor browser had its body silently replaced with the 8 bytes "<object>". jsFetchDmsg (cmd/wasm-visor/main.go) and jsFetchClearnet (skysocks_js.go) read the body with []byte(args[3].String()); browse-responder.js passes it as a Uint8Array, and syscall/js Value.String() on a non-string returns the literal "<object>".

Verified live (byte-for-byte)

Mesh HTTP echo served over .dmsg, SW-controlled iframe on the :8443 harness vs a native SOCKS client (curl on :4445→:4446→:1080):

  • GET / subresources(img,css) / XHR / 302-redirect: ✓ before and after
  • POST (form) x=42&y=sky: before → echo "<object>" (8 bytes); after → x=42&y=sky (10) ✓
  • POST (binary) [1,2,3,255,0,66]: 6 bytes preserved ✓
  • Same body both ways → identical: {"method":"POST","echo":"PARITY_test_&z=9","len":16}

This completes the wasm-iframe browser's request-type matrix (navigation, subresources, XHR, redirects, POSTs) at byte-for-byte parity with the SOCKS5 resolving-proxy chain.

Fix

jsBodyBytes(js.Value): strings pass through; Uint8Array / typed arrays / DataView / ArrayBuffer copied out via js.CopyBytesToGo. Used by both fetch bindings. Includes the regenerated std-Go embed blob built clean on top of the code fix.

0pcom added 2 commits August 15, 2026 03:12
…ject>"

jsFetchDmsg and jsFetchClearnet read the optional request body with
`[]byte(args[3].String())`. The real-origin browse responder
(browse-responder.js) passes the body as a Uint8Array, and syscall/js
Value.String() on a non-string value returns the literal string
"<object>" — so every browser POST/PUT issued through the in-tab
wasm-visor browser had its body silently replaced with the 8 bytes
"<object>" before it left the visor. Confirmed live: a mesh browse
POST of "x=42&y=sky" arrived at the server as "<object>" (GET, XHR and
302-redirect all worked; only the body was corrupted).

Add jsBodyBytes(): string bodies pass through as before; Uint8Array,
other typed arrays / DataView, and ArrayBuffer are copied out with
js.CopyBytesToGo. Used by both fetch bindings, so form-encoded and
binary POSTs (browser uploads, skycoin-API form posts) carry their real
bytes.
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