Skip to content

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

Description

@124C41p

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions