I am trying to rum the todo app in the YEW framework (examples folder). I cloned the project and followed the default instructions. The todo app runs but crashes when I try to use it. I tried Chrome and Firefox and some older releases of the framework. Given that it’s impossible to get an error stack trace in Rust in the browser, is there any way to debug a YEW application? Also, given that I cannot run some of the YEW examples, is the framework stable enough for production?
The logging to console works fine with Yew. See the web_logger crate ( https://github.com/DenisKolodin/web_logger ).
Here’s an example yew app we went through at the Rustfest 2018 yew workshop:
Hope this helps! Agree no stacktrace yet for wasm, but that’s got to be really high on the todo list for this year.
You mentioned the exampled didn’t work, you’ve probably done this, but for the rust wasm you need to:
cargo install cargo-web
and then rather than
cargo run you execute
cargo web start If I remember correctly. (And also install the wasm target via rustup)
I’ve done all of that. The todo app compiles and runs, but when I try to do something it usually crashes after I enter a few tasks. I was wondering if I have to use Rust nightly build (I’m using the latest Rust stable).
That is my console in Firefox:
pre-main prep time: 4 ms
DEBUG:yew::html::onkeypress – Event handler: KeyPressEvent
Encountered a panic!
Panic error message: already borrowed: BorrowMutError
Panic location: libcore/result.rs:945
DEBUG:yew::html::oninput – Event handler: InputEvent
uncaught exception: 5321952
Source map error: request failed with status 404
Resource URL: http://127.0.0.1:8000/js/app.js
Source Map URL: todomvc-642eb429035a3655.js.map[Learn More]
It actually fails with emscripten with borrowing of a scheduler. But it will work reliable and faster if you will use
--target wasm32-unknown-unknown target.
On other hand this bug has disappeared with a new scheduler which I’ll merge soon: https://github.com/DenisKolodin/yew/pull/272
It’s possible to use it for a production project, but the framework continues to improve and could get some backward incompatible changes. You should take this risk into account. But the framework already is so close to a consistent state.
I had some trouble to get the nightly build running but it worked. The todo example is working fine.