MabezDev / wokwi-server

Other
62 stars 8 forks source link

Report errors in case listen on port 9012 fails #15

Closed andy31415 closed 1 year ago

andy31415 commented 1 year ago

I was using https://github.com/esp-rs/esp-idf-template with devcontainers enabled to try wokwi. It turns out the devcontainer (helpfully!) tries to listen on port 9012 and redirect it. The sideffect from this though is that if trying to run wowki-server on the host rather than the VM, I get a "Address already in use".

Unforunately it seems that he current task code returns Ok(Err(_)) in case of await errors and NOT the expected Err(_) so the program would just silently stop for me which was annoying to debug. Note that task is of type Option<Result<Result<(), Error>, JoinError>> (!). So we need to treat both JoinError AND the underlying result/error.

I made the following changes:

After the change, I get:

 ❯ cargo run -- --chip esp32c3 ../../rust_development/c3/hello-world/target/riscv32imc-esp-espidf/debug/hello-world
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/wokwi-server --chip esp32c3 ../../rust_development/c3/hello-world/target/riscv32imc-esp-espidf/debug/hello-world`
Task failed: Failed to listen on 127.0.0.1:9012

Caused by:
    Address already in use (os error 98)

without it, it would just silently finish.