feat(core): update v8 to 146.8.0 with foreground task ownership#32771
Merged
bartlomieju merged 10 commits intomainfrom Mar 18, 2026
Merged
feat(core): update v8 to 146.8.0 with foreground task ownership#32771bartlomieju merged 10 commits intomainfrom
bartlomieju merged 10 commits intomainfrom
Conversation
Updates the v8 crate to 146.8.0 which includes rusty_v8#1934. The custom V8 platform now receives ownership of foreground tasks via v8::Task and v8::IdleTask types, instead of tasks being queued in the default platform. This eliminates the need for PumpMessageLoop and lets deno_core run V8 foreground tasks directly on the event loop. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instead of manually queuing tasks in a registry and draining them in the event loop, spawn them directly onto the isolate's tokio runtime handle. This removes the timer thread, task queues, and the PumpMessageLoop call entirely. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Verifies that V8 foreground tasks are delivered to the correct isolate when multiple workers use Atomics.waitAsync concurrently. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Some unit tests and snapshot creation run JsRuntime without a tokio runtime. Use try_current() to gracefully skip waker registration instead of panicking. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
devsnek
reviewed
Mar 16, 2026
libs/core/runtime/setup.rs
Outdated
| if let Some(entry) = map.get(&key) { | ||
| let waker = entry.waker.clone(); | ||
| entry.handle.spawn(async move { | ||
| task.run(0.0); |
Member
There was a problem hiding this comment.
v8 uses the value passed here like this for example:
while (deadline_in_seconds > platform_->MonotonicallyIncreasingTime()) {
so if you want the job to actually do anything you need to pass a value greater than the current monotonic timestamp.
in chromium all the idle tasks are queued together. and when there is idle time in the render process it will calculate a deadline and drain that queue until empty or it runs out of time.
this approach doesn't make much sense in server runtimes, so some other behavior needs to be selected i guess? but also worth noting is that in node the PostIdleTaskImpl just calls UNREACHABLE(), so maybe we don't need to care about it.
V8 idle tasks check `deadline > MonotonicallyIncreasingTime()`, so passing 0.0 makes them no-ops. Node also ignores idle tasks entirely. Just drop them without running. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Idle tasks are not used in server runtimes — Node also marks this as UNREACHABLE(). Panic if V8 ever posts one unexpectedly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Immediate foreground tasks must run synchronously during the event loop poll to preserve microtask/timer ordering and ensure the event loop sees their effects before checking pending state. Delayed tasks use tokio::spawn with tokio::time::sleep. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove `pump_v8_message_loop` from `PollEventLoopOptions` — foreground tasks are now always drained unconditionally on every event loop tick. - Share the `ForegroundTaskQueue` (Arc<Mutex<Vec<v8::Task>>>) between `JsRuntimeState` and the global platform registry so the event loop drains tasks from its local Arc without touching the global map. - Delayed tasks now queue into the shared Vec after sleeping instead of running directly on a tokio worker thread, ensuring they execute on the isolate's foreground thread. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove needless `..Default::default()` now that the struct has only one field. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
devsnek
approved these changes
Mar 18, 2026
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
v8crate from 146.5.0 to 146.8.0 (includes rusty_v8#1934)DenoPlatformImplto receivev8::Task/v8::IdleTaskownership from the C++ custom platform, instead of tasks being queued inDefaultPlatformPumpMessageLoopTest plan
cargo checkpasses (full workspace)tools/format.jscleantools/lint.jscleantest_pump_message_loopandatomics_wait_async_notifyspec tests validate foreground task delivery🤖 Generated with Claude Code