jco icon indicating copy to clipboard operation
jco copied to clipboard

Failure to run `wstd` `http-client` example wasm binary

Open dragonflyfree opened this issue 10 months ago • 4 comments

https://github.com/yoshuawuyts/wstd/blob/main/examples/http_client.rs cargo 1.87.0-nightly (1d1d646c0 2025-02-21), Rust edition 2021, cargo component build --release --target wasm32-wasip2

import { run } from "./transpiled/wstd-example.js"

console.log(run.run())

When running node index.js https://example.com:

> GET / HTTP/1.1
< HTTP/1.1 200 OK
< content-type: text/html
< etag: "84238dfc8092e5d9c0dac8ef93371a07:1736799080.121134"
< last-modified: Mon, 13 Jan 2025 20:11:20 GMT
< cache-control: max-age=697
< date: Wed, 26 Feb 2025 04:00:26 GMT
< alt-svc: h3=":443"; ma=93600,h3-29=":443"; ma=93600,quic=":443"; ma=93600; v="43"
< content-length: 1256
< connection: keep-alive
.../node_modules/@bytecodealliance/preview2-shim/lib/io/worker-io.js:323
      { src: src.#id, len }
                 ^

TypeError: Cannot read private member #id from an object whose class did not declare it
    at OutputStream.splice (.../node_modules/@bytecodealliance/preview2-shim/lib/io/worker-io.js:323:18)      
    at trampoline56 (.../transpiled/wstd-example.js:2917:34)
    at wit-component:shim.indirect-wasi:io/[email protected][method]output-stream.splice (wasm://wasm/wit-component:shim-b13bbaba:wasm-function[16]:0x283)
    at wasm://wasm/001e552a:wasm-function[184]:0x7504
    at wasm://wasm/001e552a:wasm-function[281]:0x16dc8
    at wasm://wasm/001e552a:wasm-function[279]:0x103e0
    at wasm://wasm/001e552a:wasm-function[96]:0x3286
    at wasm://wasm/001e552a:wasm-function[329]:0x24c61
    at wasm://wasm/001e552a:wasm-function[61]:0x148e
    at wit-component:adapter:wasi_snapshot_preview1.wasi:cli/[email protected]#run (wasm://wasm/wit-component:adapter:wasi_snapshot_preview1-2fd92fea:wasm-function[29]:0x701)

Node.js v22.5.1

dragonflyfree avatar Feb 26 '25 04:02 dragonflyfree

Just to clarify for anyone trying to reproduce, with wstd cloned you can run:

cargo component build --release --example http_client --target wasm32-wasip2

I've removed the static function machinery for retrieving ids which fixed the immediate problem, but now I'm finding an issue in which the component looks to be trying to check for pollable ready of a pollable that was never created...

vados-cosmonic avatar Feb 26 '25 05:02 vados-cosmonic

An update here to mirror the PR -- the member access issues are one thing, but the deeper issue looks to be currently incomplete trailer support Jco -- we'll have to add in support there for this example to fully work.

In the meantime @dragonflyfree if you don't absolutely need trailers, then please clip them from the component you're trying to run.

vados-cosmonic avatar Feb 26 '25 09:02 vados-cosmonic

There's another intermediate fix we could add here for an error saying trailers are unsupported.

guybedford avatar Mar 10 '25 16:03 guybedford

The example in wstd is just trying to read out the values of trailers - returning none trailers, like wasmtime does, is a suitable implementation. Wasmtime doesn't have any path to read out the real value of trailers (afaik, no implementation does, but I'd love to be wrong) but the trivial none trailers implementation should be possible in jco.

pchickey avatar Mar 10 '25 18:03 pchickey