Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get worker running #7

Open
MTRNord opened this issue Aug 25, 2020 · 11 comments
Open

Unable to get worker running #7

MTRNord opened this issue Aug 25, 2020 · 11 comments

Comments

@MTRNord
Copy link

MTRNord commented Aug 25, 2020

Hi I have a yew worker (I updated this to the latest yew) but I am getting some errors:

grafik

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?

@MTRNord
Copy link
Author

MTRNord commented Aug 25, 2020

@MTRNord MTRNord closed this as completed Aug 25, 2020
@MTRNord MTRNord reopened this Aug 25, 2020
@MTRNord
Copy link
Author

MTRNord commented Aug 25, 2020

@MTRNord
Copy link
Author

MTRNord commented Aug 25, 2020

Apparently self.location is blob:http://localhost:8000/e2622e85-1f6e-4cd7-8d7b-8f144c6eee01 :/

@MTRNord
Copy link
Author

MTRNord commented Aug 25, 2020

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

@MTRNord
Copy link
Author

MTRNord commented Aug 25, 2020

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.

@MTRNord
Copy link
Author

MTRNord commented Aug 25, 2020

grafik

This is now the only left issue

@dunnock
Copy link
Owner

dunnock commented Aug 26, 2020

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

@MTRNord
Copy link
Author

MTRNord commented Aug 26, 2020

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

@MTRNord
Copy link
Author

MTRNord commented Aug 26, 2020

Seems like the complete "world" of wasm-bindgen is missing.

grafik

@dunnock
Copy link
Owner

dunnock commented Aug 27, 2020

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 wasmerio/wasmer-js#241

@dunnock
Copy link
Owner

dunnock commented Aug 28, 2020

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)

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

No branches or pull requests

2 participants