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

Illegal invocation with wasm client #971

Closed
DogLooksGood opened this issue Jan 16, 2023 · 8 comments · Fixed by #978
Closed

Illegal invocation with wasm client #971

DogLooksGood opened this issue Jan 16, 2023 · 8 comments · Fixed by #978

Comments

@DogLooksGood
Copy link

Ran into this error after a succeed json rpc call. From the browser network console I can see the request and response in WebSocket frames. I'm not sure if it's related to jsonrpsee, please let me know what information may help.

image

The error in Chrome is

Uncaught (in promise) TypeError: Illegal invocation
    at __wbg_clearTimeout_23ee6db72c0ad922 (index.js:158:121)
    at gloo_timers::callback::clear_timeout::he7626a9b97580d77 (352474e57d4049a2e339.module.wasm:0x382f9f)
    at <gloo_timers::callback::Timeout as core::ops::drop::Drop>::drop::hac00a6491c31414b (352474e57d4049a2e339.module.wasm:0x350f8f)
    at core::ptr::drop_in_place<gloo_timers::callback::Timeout>::hcf33a47264f7589a (352474e57d4049a2e339.module.wasm:0x37f732)
    at core::ptr::drop_in_place<gloo_timers::future::TimeoutFuture>::h1149ae5a04cfeb8c (352474e57d4049a2e339.module.wasm:0x37f6a5)
    at core::ptr::drop_in_place<alloc::boxed::Box<gloo_timers::future::TimeoutFuture>>::h02896cee9121c7fa (352474e57d4049a2e339.module.wasm:0x37de7c)
    at <send_wrapper::SendWrapper<T> as core::ops::drop::Drop>::drop::ha4fb0469d2e1f7a0 (352474e57d4049a2e339.module.wasm:0x3160cf)
    at core::ptr::drop_in_place<send_wrapper::SendWrapper<gloo_timers::future::TimeoutFuture>>::h48c59c6af83ce19c (352474e57d4049a2e339.module.wasm:0x392150)
    at core::ptr::drop_in_place<futures_timer::wasm::Delay>::h3b8c26720a0684a8 (352474e57d4049a2e339.module.wasm:0x39175c)
    at jsonrpsee_core::client::async_client::helpers::call_with_timeout::{{closure}}::h3cdc56fa3a4130ba (352474e57d4049a2e339.module.wasm:0x135d04)

The error in Firefox seems to be more accurate:

Uncaught (in promise) TypeError: 'clearTimeout' called on an object that does not implement interface Window.
    __wbg_clearTimeout_23ee6db72c0ad922 http://localhost:8080/index.js:158
[index.js:158:83](http://localhost:8080/index.js)
    real index_bg.js:212
    (Async: promise callback)
    __wbg_then_11f7a54d67b4bfad index_bg.js:662
    logError index_bg.js:223
    __wbg_then_11f7a54d67b4bfad index_bg.js:661
    __wbg_then_11f7a54d67b4bfad index.js:194

The Rust code:

async fn create_game_account(&self, params: CreateGameAccountParams) -> Result<String> {
    self.client
        .request("create_game", rpc_params![params])
        .await
        .map_err(|e| Error::RpcError(e.to_string()))
}
@niklasad1
Copy link
Member

niklasad1 commented Jan 16, 2023

It looks like call was canceled due to a RequestTimeout which is triggered by jsonrpsee (the timeout is 60s by default), looks like a regression in rustwasm/gloo#283

You could temporary increase the timeout here to get rid of these but this only works on master currently, it will be in the next release.

Hopefully rustwasm/gloo#283 will be merged soon 🙏

@DogLooksGood
Copy link
Author

Yeah, it seems to be the case, will try with that PR.
BTW, since it all happens on my local machine, the RPC server responds instantly. So I guess it's not timeout related.

@niklasad1
Copy link
Member

niklasad1 commented Jan 16, 2023

Ok, you also could enable logging from jsonrpsee (https://github.com/paritytech/jsonrpsee/blob/master/tests/wasm-tests/tests/wasm.rs#L15-#L18) to see whether the message gets stuck somewhere.

What does the timestamps from the browser say?

I'm a little concerned about the backtrace but it could also be something that gloo triggers but I could try to reproduce this.

@DogLooksGood
Copy link
Author

What do you mean by "timestamps"? It all happened in a few milliseconds, I think.

It's weird that, I can only reproduce it by calling my WASM code from JS, if I use wasm-bindgen-test, it actually works without issue. How can I enable log then?

@niklasad1
Copy link
Member

niklasad1 commented Jan 17, 2023

What do you mean by "timestamps"? It all happened in a few milliseconds, I think.

Yeah, I meant how long it took for the round trip for the message.

https://crates.io/crates/tracing-wasm works with the current logs that jsonrpsee has but it doesn't work in some environments such as node.js.

I haven't tried it myself from JS but we could probably add some console_log if needed.

@DogLooksGood
Copy link
Author

Yeah, I meant how long it took for the round trip for the message.

It completed instantly, so I think it's not the timeout case.

I just created a repo for reproduction, please check it out.
https://github.com/DogLooksGood/illegal-invocation-repro

@DogLooksGood
Copy link
Author

Update to gloo-timers 0.2.6 will solve this.

@niklasad1
Copy link
Member

niklasad1 commented Jan 21, 2023

awesome, thanks for helping the gloo devs.

I opened a PR to require ^0.2.6 for gloo-net which contains the fix.

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 a pull request may close this issue.

2 participants