refactor(runtime): use tokio LocalRuntime instead of MaskFutureAsSend#33273
Open
bartlomieju wants to merge 1 commit intomainfrom
Open
refactor(runtime): use tokio LocalRuntime instead of MaskFutureAsSend#33273bartlomieju wants to merge 1 commit intomainfrom
bartlomieju wants to merge 1 commit intomainfrom
Conversation
Tokio 1.52 stabilized `LocalRuntime` which natively supports spawning `!Send` futures without the unsafe `MaskFutureAsSend` workaround. - Upgrade tokio from 1.47.1 to 1.52.0 - Convert `create_basic_runtime()` to return `LocalRuntime` via `build_local()` - Replace `MaskFutureAsSend` + `rt.spawn()` with `rt.spawn_local()` in `create_and_run_current_thread_inner` - Replace `deno_unsync::spawn` callsites with `tokio::task::spawn_local` - Replace `deno_unsync::spawn_blocking` callsites with `tokio::task::spawn_blocking` - Create `libs/core/unsync.rs` module that re-exports tokio's native task spawning alongside remaining deno_unsync utilities - Convert inspector server from `Runtime` + `LocalSet` to `LocalRuntime` Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LocalRuntimeMaskFutureAsSend+rt.spawn()pattern withLocalRuntime::spawn_local()which natively supports!Sendfutures without unsafedeno_unsync::spawn/spawn_blocking/JoinHandlewith tokio's nativespawn_local/spawn_blocking/JoinHandleacross the codebaseRuntime+LocalSettoLocalRuntime, eliminating theLocalSetindirectionlibs/core/unsync.rsas a re-export module so all existingdeno_core::unsync::spawn(...)callsites automatically usetokio::task::spawn_localMaskFutureAsSendremains available (and used incli/module_loader.rs) for the case where a!Sendfuture must be moved across a thread boundary -- that's a RustSendconstraint, not a tokio runtime issue.The sync primitives from
deno_unsync(AtomicFlag,TaskQueue,UnsyncWaker, etc.) are unaffected and still used.Test plan
cargo checkpasses./x fmtclean🤖 Generated with Claude Code