DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
21.44k stars 826 forks source link

Panic when restarting UseFuture #681

Closed terhechte closed 1 year ago

terhechte commented 1 year ago

Problem

I have a super simple example that panics on latest master when tapping the button that restarts the future.

#![allow(non_snake_case)]

use dioxus::prelude::*;
use dioxus_web::launch;

fn main() {
    launch(App);
}

pub async fn query() -> usize {
    0
}

fn App(cx: Scope) -> Element {
    let search_future = use_future(cx, (), |_| async { query().await });
    cx.render(rsx!(
        button {
            onclick: move |_| search_future.restart(),
            "Bang"
        }
    ))
}

Steps To Reproduce

Steps to reproduce the behavior:

Expected behavior

No Panic

Logs

It generates multiple panics, here's the console output:

panicked at 'invalid key', /Users/terhechte/.cargo/git/checkouts/dioxus-1e619ce595d3799d/4aac2cd/packages/core/src/scheduler/task.rs:57:33

Stack:

Error
    at http://localhost:8080/assets/dioxus/dioxus.js:348:17
    at logError (http://localhost:8080/assets/dioxus/dioxus.js:222:18)
    at imports.wbg.__wbg_new_abda76e883ba8a5f (http://localhost:8080/assets/dioxus/dioxus.js:347:62)
    at console_error_panic_hook::Error::new::h9b4677e6dda9c899 (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[6655]:0x1f5dc1)
    at console_error_panic_hook::hook_impl::h0b31cc64b826b15d (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[1227]:0x11ee65)
    at console_error_panic_hook::hook::h126984eb884be373 (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[7268]:0x1fe4ad)
    at core::ops::function::Fn::call::h11b6cce109ab90eb (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[6344]:0x1f10c6)
    at std::panicking::rust_panic_with_hook::he04cb00575f2a1e3 (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[2653]:0x182ebd)
    at std::panicking::begin_panic_handler::{{closure}}::hb733f0aa505760cf (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[3510]:0x1aa356)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h6beefa0bcab220bc (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[7654]:0x2033d2)

(anonymous) @ dioxus.js:345
logError @ dioxus.js:222
imports.wbg.__wbg_error_f851667af71bcfc6 @ dioxus.js:342
$console_error_panic_hook::error::ha54df1d32b6cbe43 @ dioxus_bg.wasm:0x1a33af
$console_error_panic_hook::hook_impl::h0b31cc64b826b15d @ dioxus_bg.wasm:0x11ef51
$console_error_panic_hook::hook::h126984eb884be373 @ dioxus_bg.wasm:0x1fe4ad
$core::ops::function::Fn::call::h11b6cce109ab90eb @ dioxus_bg.wasm:0x1f10c6
$std::panicking::rust_panic_with_hook::he04cb00575f2a1e3 @ dioxus_bg.wasm:0x182ebd
$std::panicking::begin_panic_handler::{{closure}}::hb733f0aa505760cf @ dioxus_bg.wasm:0x1aa356
$std::sys_common::backtrace::__rust_end_short_backtrace::h6beefa0bcab220bc @ dioxus_bg.wasm:0x2033d2
$rust_begin_unwind @ dioxus_bg.wasm:0x1dfccd
$core::panicking::panic_fmt::h586d720a90aa8503 @ dioxus_bg.wasm:0x1fced1
$core::panicking::panic_display::he96fafaefe672510 @ dioxus_bg.wasm:0x1f0bce
$core::panicking::panic_str::h8b2f06f6f011655d @ dioxus_bg.wasm:0x20534e
$core::option::expect_failed::h1e9a9cbb22bbd6ac @ dioxus_bg.wasm:0x2085ae
$core::option::Option<T>::expect::hbc6f24126943c0d0 @ dioxus_bg.wasm:0x1c7f04
$slab::Slab<T>::remove::h22c9de19fc90ff48 @ dioxus_bg.wasm:0x1dda8d
$dioxus_core::scheduler::task::<impl dioxus_core::scheduler::Scheduler>::remove::hcc4282ac464fa058 @ dioxus_bg.wasm:0x18f7fe
$dioxus_core::scopes::ScopeState::remove_future::h70f9a19796c1b95a @ dioxus_bg.wasm:0x1c4434
$dioxus_hooks::usefuture::use_future::h5460c1ba07041218 @ dioxus_bg.wasm:0xace26
$diob::App::hf308d330ff91da42 @ dioxus_bg.wasm:0x1acbfd
$<dioxus_core::any_props::VProps<P,A,F> as dioxus_core::any_props::AnyProps>::render::{{closure}}::ha56e401fab4b7287 @ dioxus_bg.wasm:0x9315c
$core::ops::function::FnOnce::call_once::h41c4404ddf9c5b5c @ dioxus_bg.wasm:0x1f2225
$<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h5b67f360946fec31 @ dioxus_bg.wasm:0x1f4d7b
$std::panicking::try::do_call::hd50fabf5cf8eed36 @ dioxus_bg.wasm:0x1576cb
$std::panicking::try::h23121ce4edf65b64 @ dioxus_bg.wasm:0x14c3a8
$std::panic::catch_unwind::hf4379213b7a6d3a5 @ dioxus_bg.wasm:0x1f4935
$<dioxus_core::any_props::VProps<P,A,F> as dioxus_core::any_props::AnyProps>::render::hbdbdc8d761ce346e @ dioxus_bg.wasm:0x147fd2
$dioxus_core::scope_arena::<impl dioxus_core::virtual_dom::VirtualDom>::run_scope::h211d354ef45494c4 @ dioxus_bg.wasm:0x2f1ba
$dioxus_core::virtual_dom::VirtualDom::render_with_deadline::{{closure}}::h4817dd0c419178e1 @ dioxus_bg.wasm:0x28256
$<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9205dc5e095c0f0a @ dioxus_bg.wasm:0xab13c
$dioxus_core::virtual_dom::VirtualDom::render_immediate::h5549da3fc6f2e9d9 @ dioxus_bg.wasm:0xb8bc0
$dioxus_web::run_with_props::{{closure}}::h94b1d229fe45f0fb @ dioxus_bg.wasm:0x1984f
$<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h26c9733403f5f42a @ dioxus_bg.wasm:0x180039
$wasm_bindgen_futures::task::singlethread::Task::run::hd4650a01c0bc8081 @ dioxus_bg.wasm:0xf9237
$wasm_bindgen_futures::queue::QueueState::run_all::haab43c3a7cc2e42b @ dioxus_bg.wasm:0xdecb5
$wasm_bindgen_futures::queue::Queue::new::{{closure}}::hb200c76a992c518c @ dioxus_bg.wasm:0x1bddbb
$<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hf200a9fb8598df1c @ dioxus_bg.wasm:0x186edc
__wbg_adapter_28 @ dioxus.js:266
real @ dioxus.js:205
Promise.then (async)
(anonymous) @ dioxus.js:903
logError @ dioxus.js:222
imports.wbg.__wbg_then_11f7a54d67b4bfad @ dioxus.js:902
$js_sys::Promise::then::hc28f19ec91d7ea98 @ dioxus_bg.wasm:0x1d0086
$wasm_bindgen_futures::queue::Queue::schedule_task::h13c7977a7b08063a @ dioxus_bg.wasm:0x12c6ee
$wasm_bindgen_futures::queue::Queue::push_task::hfdf194785d2c54f9 @ dioxus_bg.wasm:0x1f5e0f
$wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::{{closure}}::h4845a47dee59904b @ dioxus_bg.wasm:0x1e25cb
$std::thread::local::LocalKey<T>::try_with::hda92f437dfe33141 @ dioxus_bg.wasm:0x13f87e
$std::thread::local::LocalKey<T>::with::h57c6258cd0f4d520 @ dioxus_bg.wasm:0x1a1e98
$wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::haccf5cbf283a2ca4 @ dioxus_bg.wasm:0x18af1a
$wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::h17c3b79b38900b20 @ dioxus_bg.wasm:0x1cf73e
$core::task::wake::Waker::wake::ha680dec50c0d9b20 @ dioxus_bg.wasm:0x1d8c55
$futures_core::task::__internal::atomic_waker::AtomicWaker::wake::h128aa32f1d7e1f0e @ dioxus_bg.wasm:0x11c46d
$futures_channel::mpsc::UnboundedSenderInner<T>::queue_push_and_signal::h3ae719da490a59c7 @ dioxus_bg.wasm:0x157a21
$futures_channel::mpsc::UnboundedSender<T>::do_send_nb::h44b88743ffb0d3a0 @ dioxus_bg.wasm:0xa5342
$futures_channel::mpsc::UnboundedSender<T>::unbounded_send::h7d59e0b817bcd379 @ dioxus_bg.wasm:0x171466
$dioxus_web::dom::WebsysDom::new::{{closure}}::h38c83e4e811ce8f3 @ dioxus_bg.wasm:0x97483
$<dyn core::ops::function::FnMut<(&A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h0a96814ed16933af @ dioxus_bg.wasm:0x1667fe
__wbg_adapter_22 @ dioxus.js:251
real @ dioxus.js:205
dioxus.js:345 panicked at 'already borrowed: BorrowMutError', /Users/terhechte/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-futures-0.4.33/src/task/singlethread.rs:85:37

Stack:

Error
    at http://localhost:8080/assets/dioxus/dioxus.js:348:17
    at logError (http://localhost:8080/assets/dioxus/dioxus.js:222:18)
    at imports.wbg.__wbg_new_abda76e883ba8a5f (http://localhost:8080/assets/dioxus/dioxus.js:347:62)
    at console_error_panic_hook::Error::new::h9b4677e6dda9c899 (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[6655]:0x1f5dc1)
    at console_error_panic_hook::hook_impl::h0b31cc64b826b15d (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[1227]:0x11ee65)
    at console_error_panic_hook::hook::h126984eb884be373 (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[7268]:0x1fe4ad)
    at core::ops::function::Fn::call::h11b6cce109ab90eb (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[6344]:0x1f10c6)
    at std::panicking::rust_panic_with_hook::he04cb00575f2a1e3 (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[2653]:0x182ebd)
    at std::panicking::begin_panic_handler::{{closure}}::hb733f0aa505760cf (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[3510]:0x1aa356)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h6beefa0bcab220bc (http://localhost:8080/assets/dioxus/dioxus_bg.wasm:wasm-function[7654]:0x2033d2)

(anonymous) @ dioxus.js:345
logError @ dioxus.js:222
imports.wbg.__wbg_error_f851667af71bcfc6 @ dioxus.js:342
$console_error_panic_hook::error::ha54df1d32b6cbe43 @ dioxus_bg.wasm:0x1a33af
$console_error_panic_hook::hook_impl::h0b31cc64b826b15d @ dioxus_bg.wasm:0x11ef51
$console_error_panic_hook::hook::h126984eb884be373 @ dioxus_bg.wasm:0x1fe4ad
$core::ops::function::Fn::call::h11b6cce109ab90eb @ dioxus_bg.wasm:0x1f10c6
$std::panicking::rust_panic_with_hook::he04cb00575f2a1e3 @ dioxus_bg.wasm:0x182ebd
$std::panicking::begin_panic_handler::{{closure}}::hb733f0aa505760cf @ dioxus_bg.wasm:0x1aa356
$std::sys_common::backtrace::__rust_end_short_backtrace::h6beefa0bcab220bc @ dioxus_bg.wasm:0x2033d2
$rust_begin_unwind @ dioxus_bg.wasm:0x1dfccd
$core::panicking::panic_fmt::h586d720a90aa8503 @ dioxus_bg.wasm:0x1fced1
$core::result::unwrap_failed::h1d03d3774c363770 @ dioxus_bg.wasm:0x1c0899
$core::cell::RefCell<T>::borrow_mut::hd70cea7b35233a9e @ dioxus_bg.wasm:0x18e735
$wasm_bindgen_futures::task::singlethread::Task::run::hd4650a01c0bc8081 @ dioxus_bg.wasm:0xf910c
$wasm_bindgen_futures::queue::QueueState::run_all::haab43c3a7cc2e42b @ dioxus_bg.wasm:0xdecb5
$wasm_bindgen_futures::queue::Queue::new::{{closure}}::hb200c76a992c518c @ dioxus_bg.wasm:0x1bddbb
$<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hf200a9fb8598df1c @ dioxus_bg.wasm:0x186edc
__wbg_adapter_28 @ dioxus.js:266
real @ dioxus.js:205
Promise.then (async)
(anonymous) @ dioxus.js:903
logError @ dioxus.js:222
imports.wbg.__wbg_then_11f7a54d67b4bfad @ dioxus.js:902
$js_sys::Promise::then::hc28f19ec91d7ea98 @ dioxus_bg.wasm:0x1d0086
$wasm_bindgen_futures::queue::Queue::schedule_task::h13c7977a7b08063a @ dioxus_bg.wasm:0x12c6ee
$wasm_bindgen_futures::queue::Queue::push_task::hfdf194785d2c54f9 @ dioxus_bg.wasm:0x1f5e0f
$wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::{{closure}}::h4845a47dee59904b @ dioxus_bg.wasm:0x1e25cb
$std::thread::local::LocalKey<T>::try_with::hda92f437dfe33141 @ dioxus_bg.wasm:0x13f87e
$std::thread::local::LocalKey<T>::with::h57c6258cd0f4d520 @ dioxus_bg.wasm:0x1a1e98
$wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::haccf5cbf283a2ca4 @ dioxus_bg.wasm:0x18af1a
$wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::h17c3b79b38900b20 @ dioxus_bg.wasm:0x1cf73e
$core::task::wake::Waker::wake::ha680dec50c0d9b20 @ dioxus_bg.wasm:0x1d8c55
$futures_core::task::__internal::atomic_waker::AtomicWaker::wake::h128aa32f1d7e1f0e @ dioxus_bg.wasm:0x11c46d
$futures_channel::mpsc::UnboundedSenderInner<T>::queue_push_and_signal::hbd99af4617735563 @ dioxus_bg.wasm:0x1c9c18
$futures_channel::mpsc::UnboundedSender<T>::do_send_nb::hf99faf761691ebc0 @ dioxus_bg.wasm:0x12564b
$futures_channel::mpsc::UnboundedSender<T>::unbounded_send::h722efbfd244c4e0e @ dioxus_bg.wasm:0x1ebd74
$dioxus_core::scopes::ScopeState::schedule_update::{{closure}}::h71ce4a5fbb65e840 @ dioxus_bg.wasm:0x1ccc51
$dioxus_hooks::usefuture::UseFuture<T>::restart::h29494dbd3bd0dabc @ dioxus_bg.wasm:0x1c4abc
$diob::App::{{closure}}::{{closure}}::h327e576d6b85ea16 @ dioxus_bg.wasm:0x1e1ece
$dioxus_core::scopes::ScopeState::listener::{{closure}}::h271534889b387957 @ dioxus_bg.wasm:0xfe2e3
$dioxus_core::virtual_dom::VirtualDom::handle_event::h35da0d1e0d1ad54f @ dioxus_bg.wasm:0x3c12d
$dioxus_web::run_with_props::{{closure}}::h94b1d229fe45f0fb @ dioxus_bg.wasm:0x19a21
$<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h26c9733403f5f42a @ dioxus_bg.wasm:0x180039
$wasm_bindgen_futures::task::singlethread::Task::run::hd4650a01c0bc8081 @ dioxus_bg.wasm:0xf9237
$wasm_bindgen_futures::queue::QueueState::run_all::haab43c3a7cc2e42b @ dioxus_bg.wasm:0xdecb5
$wasm_bindgen_futures::queue::Queue::new::{{closure}}::hb200c76a992c518c @ dioxus_bg.wasm:0x1bddbb
$<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hf200a9fb8598df1c @ dioxus_bg.wasm:0x186edc
__wbg_adapter_28 @ dioxus.js:266
real @ dioxus.js:205
Promise.then (async)
(anonymous) @ dioxus.js:903
logError @ dioxus.js:222
imports.wbg.__wbg_then_11f7a54d67b4bfad @ dioxus.js:902
$js_sys::Promise::then::hc28f19ec91d7ea98 @ dioxus_bg.wasm:0x1d0086
$wasm_bindgen_futures::queue::Queue::schedule_task::h13c7977a7b08063a @ dioxus_bg.wasm:0x12c6ee
$wasm_bindgen_futures::queue::Queue::push_task::hfdf194785d2c54f9 @ dioxus_bg.wasm:0x1f5e0f
$wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::{{closure}}::h4845a47dee59904b @ dioxus_bg.wasm:0x1e25cb
$std::thread::local::LocalKey<T>::try_with::hda92f437dfe33141 @ dioxus_bg.wasm:0x13f87e
$std::thread::local::LocalKey<T>::with::h57c6258cd0f4d520 @ dioxus_bg.wasm:0x1a1e98
$wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::haccf5cbf283a2ca4 @ dioxus_bg.wasm:0x18af1a
$wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::h17c3b79b38900b20 @ dioxus_bg.wasm:0x1cf73e
$core::task::wake::Waker::wake::ha680dec50c0d9b20 @ dioxus_bg.wasm:0x1d8c55
$futures_core::task::__internal::atomic_waker::AtomicWaker::wake::h128aa32f1d7e1f0e @ dioxus_bg.wasm:0x11c46d
$futures_channel::mpsc::UnboundedSenderInner<T>::queue_push_and_signal::h3ae719da490a59c7 @ dioxus_bg.wasm:0x157a21
$futures_channel::mpsc::UnboundedSender<T>::do_send_nb::h44b88743ffb0d3a0 @ dioxus_bg.wasm:0xa5342
$futures_channel::mpsc::UnboundedSender<T>::unbounded_send::h7d59e0b817bcd379 @ dioxus_bg.wasm:0x171466
$dioxus_web::dom::WebsysDom::new::{{closure}}::h38c83e4e811ce8f3 @ dioxus_bg.wasm:0x97483
$<dyn core::ops::function::FnMut<(&A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h0a96814ed16933af @ dioxus_bg.wasm:0x1667fe
__wbg_adapter_22 @ dioxus.js:251
real @ dioxus.js:205
dioxus_bg.wasm:0x2088b3 Uncaught (in promise) RuntimeError: unreachable
    at __rust_start_panic (dioxus_bg.wasm:0x2088b3)
    at rust_panic (dioxus_bg.wasm:0x2052ff)
    at std::panicking::rust_panic_with_hook::he04cb00575f2a1e3 (dioxus_bg.wasm:0x182ee8)
    at std::panicking::begin_panic_handler::{{closure}}::hb733f0aa505760cf (dioxus_bg.wasm:0x1aa356)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h6beefa0bcab220bc (dioxus_bg.wasm:0x2033d2)
    at rust_begin_unwind (dioxus_bg.wasm:0x1dfccd)
    at core::panicking::panic_fmt::h586d720a90aa8503 (dioxus_bg.wasm:0x1fced1)
    at core::panicking::panic_display::he96fafaefe672510 (dioxus_bg.wasm:0x1f0bce)
    at core::panicking::panic_str::h8b2f06f6f011655d (dioxus_bg.wasm:0x20534e)
    at core::option::expect_failed::h1e9a9cbb22bbd6ac (dioxus_bg.wasm:0x2085ae)
$__rust_start_panic @ dioxus_bg.wasm:0x2088b3
$rust_panic @ dioxus_bg.wasm:0x2052ff
$std::panicking::rust_panic_with_hook::he04cb00575f2a1e3 @ dioxus_bg.wasm:0x182ee8
$std::panicking::begin_panic_handler::{{closure}}::hb733f0aa505760cf @ dioxus_bg.wasm:0x1aa356
$std::sys_common::backtrace::__rust_end_short_backtrace::h6beefa0bcab220bc @ dioxus_bg.wasm:0x2033d2
$rust_begin_unwind @ dioxus_bg.wasm:0x1dfccd
$core::panicking::panic_fmt::h586d720a90aa8503 @ dioxus_bg.wasm:0x1fced1
$core::panicking::panic_display::he96fafaefe672510 @ dioxus_bg.wasm:0x1f0bce
$core::panicking::panic_str::h8b2f06f6f011655d @ dioxus_bg.wasm:0x20534e
$core::option::expect_failed::h1e9a9cbb22bbd6ac @ dioxus_bg.wasm:0x2085ae
$core::option::Option<T>::expect::hbc6f24126943c0d0 @ dioxus_bg.wasm:0x1c7f04
$slab::Slab<T>::remove::h22c9de19fc90ff48 @ dioxus_bg.wasm:0x1dda8d
$dioxus_core::scheduler::task::<impl dioxus_core::scheduler::Scheduler>::remove::hcc4282ac464fa058 @ dioxus_bg.wasm:0x18f7fe
$dioxus_core::scopes::ScopeState::remove_future::h70f9a19796c1b95a @ dioxus_bg.wasm:0x1c4434
$dioxus_hooks::usefuture::use_future::h5460c1ba07041218 @ dioxus_bg.wasm:0xace26
$diob::App::hf308d330ff91da42 @ dioxus_bg.wasm:0x1acbfd
$<dioxus_core::any_props::VProps<P,A,F> as dioxus_core::any_props::AnyProps>::render::{{closure}}::ha56e401fab4b7287 @ dioxus_bg.wasm:0x9315c
$core::ops::function::FnOnce::call_once::h41c4404ddf9c5b5c @ dioxus_bg.wasm:0x1f2225
$<core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h5b67f360946fec31 @ dioxus_bg.wasm:0x1f4d7b
$std::panicking::try::do_call::hd50fabf5cf8eed36 @ dioxus_bg.wasm:0x1576cb
$std::panicking::try::h23121ce4edf65b64 @ dioxus_bg.wasm:0x14c3a8
$std::panic::catch_unwind::hf4379213b7a6d3a5 @ dioxus_bg.wasm:0x1f4935
$<dioxus_core::any_props::VProps<P,A,F> as dioxus_core::any_props::AnyProps>::render::hbdbdc8d761ce346e @ dioxus_bg.wasm:0x147fd2
$dioxus_core::scope_arena::<impl dioxus_core::virtual_dom::VirtualDom>::run_scope::h211d354ef45494c4 @ dioxus_bg.wasm:0x2f1ba
$dioxus_core::virtual_dom::VirtualDom::render_with_deadline::{{closure}}::h4817dd0c419178e1 @ dioxus_bg.wasm:0x28256
$<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9205dc5e095c0f0a @ dioxus_bg.wasm:0xab13c
$dioxus_core::virtual_dom::VirtualDom::render_immediate::h5549da3fc6f2e9d9 @ dioxus_bg.wasm:0xb8bc0
$dioxus_web::run_with_props::{{closure}}::h94b1d229fe45f0fb @ dioxus_bg.wasm:0x1984f
$<core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h26c9733403f5f42a @ dioxus_bg.wasm:0x180039
$wasm_bindgen_futures::task::singlethread::Task::run::hd4650a01c0bc8081 @ dioxus_bg.wasm:0xf9237
$wasm_bindgen_futures::queue::QueueState::run_all::haab43c3a7cc2e42b @ dioxus_bg.wasm:0xdecb5
$wasm_bindgen_futures::queue::Queue::new::{{closure}}::hb200c76a992c518c @ dioxus_bg.wasm:0x1bddbb
$<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hf200a9fb8598df1c @ dioxus_bg.wasm:0x186edc
__wbg_adapter_28 @ dioxus.js:266
real @ dioxus.js:205
Promise.then (async)
(anonymous) @ dioxus.js:903
logError @ dioxus.js:222
imports.wbg.__wbg_then_11f7a54d67b4bfad @ dioxus.js:902
$js_sys::Promise::then::hc28f19ec91d7ea98 @ dioxus_bg.wasm:0x1d0086
$wasm_bindgen_futures::queue::Queue::schedule_task::h13c7977a7b08063a @ dioxus_bg.wasm:0x12c6ee
$wasm_bindgen_futures::queue::Queue::push_task::hfdf194785d2c54f9 @ dioxus_bg.wasm:0x1f5e0f
$wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::{{closure}}::h4845a47dee59904b @ dioxus_bg.wasm:0x1e25cb
$std::thread::local::LocalKey<T>::try_with::hda92f437dfe33141 @ dioxus_bg.wasm:0x13f87e
$std::thread::local::LocalKey<T>::with::h57c6258cd0f4d520 @ dioxus_bg.wasm:0x1a1e98
$wasm_bindgen_futures::task::singlethread::Task::wake_by_ref::haccf5cbf283a2ca4 @ dioxus_bg.wasm:0x18af1a
$wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::h17c3b79b38900b20 @ dioxus_bg.wasm:0x1cf73e
$core::task::wake::Waker::wake::ha680dec50c0d9b20 @ dioxus_bg.wasm:0x1d8c55
$futures_core::task::__internal::atomic_waker::AtomicWaker::wake::h128aa32f1d7e1f0e @ dioxus_bg.wasm:0x11c46d
$futures_channel::mpsc::UnboundedSenderInner<T>::queue_push_and_signal::h3ae719da490a59c7 @ dioxus_bg.wasm:0x157a21
$futures_channel::mpsc::UnboundedSender<T>::do_send_nb::h44b88743ffb0d3a0 @ dioxus_bg.wasm:0xa5342
$futures_channel::mpsc::UnboundedSender<T>::unbounded_send::h7d59e0b817bcd379 @ dioxus_bg.wasm:0x171466
$dioxus_web::dom::WebsysDom::new::{{closure}}::h38c83e4e811ce8f3 @ dioxus_bg.wasm:0x97483
$<dyn core::ops::function::FnMut<(&A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h0a96814ed16933af @ dioxus_bg.wasm:0x1667fe
__wbg_adapter_22 @ dioxus.js:251
real @ dioxus.js:205
dioxus_bg.wasm:0x182ee2 Uncaught (in promise) RuntimeError: unreachable
    at std::panicking::rust_panic_with_hook::he04cb00575f2a1e3 (dioxus_bg.wasm:0x182ee2)
    at std::panicking::begin_panic_handler::{{closure}}::hb733f0aa505760cf (dioxus_bg.wasm:0x1aa356)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h6beefa0bcab220bc (dioxus_bg.wasm:0x2033d2)
    at rust_begin_unwind (dioxus_bg.wasm:0x1dfccd)
    at core::panicking::panic_fmt::h586d720a90aa8503 (dioxus_bg.wasm:0x1fced1)
    at core::result::unwrap_failed::h1d03d3774c363770 (dioxus_bg.wasm:0x1c0899)
    at core::cell::RefCell<T>::borrow_mut::hd70cea7b35233a9e (dioxus_bg.wasm:0x18e735)
    at wasm_bindgen_futures::task::singlethread::Task::run::hd4650a01c0bc8081 (dioxus_bg.wasm:0xf910c)
    at wasm_bindgen_futures::queue::QueueState::run_all::haab43c3a7cc2e42b (dioxus_bg.wasm:0xdecb5)
    at wasm_bindgen_futures::queue::Queue::new::{{closure}}::hb200c76a992c518c (dioxus_bg.wasm:0x1bddbb)

Environment:

terhechte commented 1 year ago

So I did some debugging. What happens is that the task is removed from the scheduler tasks once it finishes in wait.rs:32:

 // If the task completes...
        if task.task.borrow_mut().as_mut().poll(&mut cx).is_ready() {
            // Remove it from the scope so we dont try to double drop it when the scope dropes
            self.scopes[task.scope.0].spawned_tasks.remove(&id);

            // Remove it from the scheduler
            tasks.remove(id.0);
        }

It looks like restarting a task tries to remove the old task, which fails if the task already finished prior to that in task.rs:56:

    /// This does nto abort the task, so you'll want to wrap it in an aborthandle if that's important to you
    pub fn remove(&self, id: TaskId) {
        self.tasks.borrow_mut().remove(id.0);
    }

I have a local fix that only removes the task if it still exists. Not sure if that is the correct solution though.

ealmloff commented 1 year ago

This seems like the right approach! implemented in #718

terhechte commented 1 year ago

👍 :)