Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/workerd/io/worker.c++
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,13 @@ Worker::Worker(kj::Own<const Script> scriptParam,
auto limitScope =
script->isolate->getLimitEnforcer().enterStartupJs(lock, limitErrorOrTime);
unboundScript.run(lock);
// Flush microtasks enqueued during top-level script evaluation.
// Without this flush, microtasks (e.g. promise continuations from async
// initialization) remain on the per-isolate microtask queue and can leak across
// V8 contexts when multiple Workers share an isolate (same script, different
// zones). The leaked microtasks then execute under the wrong IoContext, making
// things go boom.
lock.runMicrotasks();
}
KJ_CASE_ONEOF(mainModule, kj::Path) {
KJ_IF_SOME(ns,
Expand Down