seed-rs/seed

Websocket example does not work

wkordalski opened this issue · 2 comments

After update to Seed 0.9.*, websocket example does not work.
It seems that WebSocketMessage::json() does not work proparely.

panicked at 'Failed to decode WebSocket text message: JsonError(Serde(JsValue("invalid type: string "{\"id\":0,\"text\":\"Some message\"}", expected struct ServerMessage at line 1 column 38")))', examples/websocket/src/client.rs:138:14

Stack:

init/imports.wbg.__wbg_new_693216e109162396/<@http://127.0.0.1:8000/pkg/package.js:1152:21
logError@http://127.0.0.1:8000/pkg/package.js:215:18
init/imports.wbg.__wbg_new_693216e109162396@http://127.0.0.1:8000/pkg/package.js:1151:66
console_error_panic_hook::Error::new::hccd56f011305d846@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[7457]:0x1d4384
console_error_panic_hook::hook_impl::h609103b39b1af7fd@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[964]:0xec92d
console_error_panic_hook::hook::h6df6fde5425a0167@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[8284]:0x1df6c0
core::ops::function::Fn::call::h34f162966a9b7be3@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[6927]:0x1cc0a6
std::panicking::rust_panic_with_hook::he2a025723e105e28@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[2026]:0x13d8d7
std::panicking::begin_panic_handler::{{closure}}::hd9f8c213ec91b9d5@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[3263]:0x174d70
std::sys_common::backtrace::__rust_end_short_backtrace::h6efd730283875809@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[9557]:0x1eb341
rust_begin_unwind@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[7834]:0x1d9927
core::panicking::panic_fmt::hb02133958c1e7d35@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[7990]:0x1dbaae
core::result::unwrap_failed::h68fdaca771c68bb6@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[3750]:0x184bf5
core::result::Result<T,E>::expect::ha7b6488927f0791c@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[1836]:0x1322a1
websocket::decode_message::hbeb01933f01a4ce9@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[374]:0x90b1c
websocket::create_websocket::{{closure}}::h28851870187967a9@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[6051]:0x1bc6ac
seed::browser::web_socket::builder::Builder<U,Ms,O>::on_message::{{closure}}::{{closure}}::h81dff72221c14fdb@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[2541]:0x157cc0
seed::browser::web_socket::builder::Builder<U,Ms,O>::on_message::{{closure}}::hf11f0d4bd8ac71b9@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[4953]:0x1a4e30
seed::browser::web_socket::builder::create_js_handler::{{closure}}::h9dc708d397b5df8c@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[1588]:0x1212d1
<dyn core::ops::function::Fn<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h7d39f5f0d431190e@http://127.0.0.1:8000/pkg/package_bg.wasm:wasm-function[2410]:0x1518ef
__wbg_adapter_28@http://127.0.0.1:8000/pkg/package.js:235:10
real@http://127.0.0.1:8000/pkg/package.js:199:20

Deserializing manually with serde_json::from_str(...) gives correct results.

@wkordalski hanks for reporting the issue.
I'll have a look at it next week.

should be fixed by #693