Open MTRNord opened 4 years ago
It for some reason seems to be this issue: https://stackoverflow.com/questions/60836401/failed-to-execute-fetch-on-workerglobalscope
The problematic line is https://github.com/dunnock/wasi-worker/blob/master/crates/wasi-worker-cli/js/src/worker.ts#L29
Apparently self.location is blob:http://localhost:8000/e2622e85-1f6e-4cd7-8d7b-8f144c6eee01
:/
And thats because the way how web-sys yew loads workers: https://github.com/yewstack/yew/blob/master/yew/src/agent/worker/mod.rs#L91-L123
So I have a horrible workaround to make it work:
First add this code to the worker.ts (THIS DOES NOT RESPECT SUBDIRECTORIES):
let fixed_url = location.href.replace("blob:", "");
let fixed_url_without_http_https = fixed_url.replace("http://", "").replace("https://", "");
var host = fixed_url_without_http_https.split("/")[0];
var scheme = fixed_url.replace(fixed_url_without_http_https, "");
let new_url = scheme + host;
var absolute_url = new_url + "/" + url;
const fetchedOriginalWasmBinary = await fetch(absolute_url);
and secondly in yew you would need to disable their wasm loading.
This is now the only left issue
hi @MTRNord , thank you for digging into this and sorry you experienced this issue. Seems these caused by new changes with Yew, I will work on upgrading it. In regards to javascript error, as it's minified it's hard to tell which function is not able to load. If you compile JS adaptor in a dev mode it will have sourcemap:
cd wasi-worker-cli/js
npm install
npm run build:dev
then you would need to rebuild wasi-worker-cli from crates/wasi-worker-cli
subdir:
cargo install --path . --force
Hi I can try that. I have a version that is updated at https://github.com/daydream-mx/wasi-worker/tree/yew-fork The fork of yew I use is based on the current master but has some minor changes like no bincode for worker to worker communication (It uses json as the stuff I pass only works with serde_json).
I will get back to this in a few hours and give you hopefully a better log
Seems like the complete "world" of wasm-bindgen is missing.
there is change in WASI specification in the rust std library with recent rust, hence wasi cannot load. I am currently trying to upgrade @wasmer/wasi first but got stuck with this issue atm https://github.com/wasmerio/wasmer-js/issues/241
I have managed to upgrade to wasmer-js with a few workarounds, related to how typescript compiler to cjs interoperates with rollup.. I've pushed commit to branch https://github.com/dunnock/wasi-worker/tree/wasmer-0_11 that far, you may try to pull changes to your branch to validate that issue with wasm bindings sorted. I've also tested this on wabench (which is still old version of yew)
Hi I have a yew worker (I updated this to the latest yew) but I am getting some errors:
I did not modify any of the JS stuff. I only updated the yew crate in here. I have no comparison with the version in this repo. Any hints?