Skip to content

Conversation

@HoKim98
Copy link

@HoKim98 HoKim98 commented Sep 26, 2025

Which issue does this PR close?

Closes #.

Rationale for this change

The BoxedStaticFuture<T> is typed as:

/// BoxedStaticFuture is the type alias of [`futures::future::BoxFuture`].
#[cfg(not(target_arch = "wasm32"))]
pub type BoxedStaticFuture<T> = futures::future::BoxFuture<'static, T>;
#[cfg(target_arch = "wasm32")]
/// BoxedStaticFuture is the type alias of [`futures::future::LocalBoxFuture`].
pub type BoxedStaticFuture<T> = futures::future::LocalBoxFuture<'static, T>;

But the current tokio executor only calls the Sendable spawn function like:

/// Executor that uses the [`tokio::task::spawn`] to execute futures.
#[derive(Default)]
pub struct TokioExecutor {}

impl Execute for TokioExecutor {
    /// Tokio's JoinHandle has its own `abort` support, so dropping handle won't cancel the task.
    fn execute(&self, f: BoxedStaticFuture<()>) {
        let _handle = tokio::task::spawn(f)
    }
}

So this PR just fixes the problem like:

/// Executor that uses the [`tokio::task::spawn`] to execute futures.
#[derive(Default)]
pub struct TokioExecutor {}

impl Execute for TokioExecutor {
    /// Tokio's JoinHandle has its own `abort` support, so dropping handle won't cancel the task.
    fn execute(&self, f: BoxedStaticFuture<()>) {
+        #[cfg(not(target_arch = "wasm32"))]
        let _handle = tokio::task::spawn(f);
+
+        #[cfg(target_arch = "wasm32")]
+        let _handle = tokio::task::spawn_local(f);
    }
}

And, there are also some clippy mutes on (WASM) targets.

What changes are included in this PR?

Are there any user-facing changes?

NONE

@HoKim98 HoKim98 requested a review from Xuanwo as a code owner September 26, 2025 09:41
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. releases-note/fix The PR fixes a bug or has a title that begins with "fix" labels Sep 26, 2025
@HoKim98 HoKim98 force-pushed the fix/tokio-wasm-spawn-local branch from a23a2c7 to fc35ad9 Compare September 26, 2025 21:43
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Sep 26, 2025
@HoKim98 HoKim98 force-pushed the fix/tokio-wasm-spawn-local branch from fc35ad9 to 5827921 Compare September 26, 2025 21:46
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Sep 26, 2025
Signed-off-by: Ho Kim <ho.kim@ulagbulag.io>
@HoKim98 HoKim98 force-pushed the fix/tokio-wasm-spawn-local branch from 5827921 to bd4ca4f Compare September 26, 2025 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/fix The PR fixes a bug or has a title that begins with "fix" size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant