Skip to content

glue::task::spawn shouldn't panic when the entire wasm program is running on a WebWorker #30

Open
@Officeyutong

Description

@Officeyutong

Recently I'm writing a wasm program using tokio_with_wasm that runs in a standalone WebWorker (meaning that I called init functions from wasm-bindgen in the worker). This program runs entirely in the worker, it only communicates with the main thread through onmessage/postMessage.

The program will just panic when calling spawn, at

From #27 (comment) I can see that tokio_with_wasm doesn't allow spawning in a blocking task to avoid undefined reference to JS objects. But in my situation, wasm program running in the WebWorker is not in a blocking task, and all JS objects it uses just stay in the Worker. spawn shouldn't panic under this situation.

The possible fix may be setting a flag to indicate whether the program is in a blocking_task, and decides to panic only when the progra was in a blocking_task.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions