gloo icon indicating copy to clipboard operation
gloo copied to clipboard

gloo-worker: Reactor does not send anything under heavy load

Open 124C41p opened this issue 6 months ago • 0 comments

Describe the Bug

When calling .send().await on a ReactorScope in an infinite loop, nothing is actually sent.

Steps to Reproduce

Spawn a web worker running the following loop.

#[reactor]
pub async fn Worker(mut scope: ReactorScope<(), u64>) {
    for i in 0.. {
        scope.send(i).await.unwrap();

        // Nothing is sent unless we uncomment the following line
        // gloo::timers::future::sleep(Duration::from_millis(100)).await;
    }
}

Log the output to the console from the main thread.

fn main() {
    wasm_bindgen_futures::spawn_local(async {
        let mut bridge = Worker::spawner().spawn("/worker.js");
        while let Some(i) = bridge.next().await {
            gloo::console::log!(i)
        }
    });
}

Expected Behavior

To see output on the console.

Actual Behavior

There is no output on the console. After uncommenting the sleep statement in the reactor function, the expected output appears.

Additional Context

Tested with gloo-worker v0.5.0 inside Firefox dev edition 128.0b3.

124C41p avatar Aug 03 '24 18:08 124C41p