diff --git a/src/wasm/module-compiler.cc b/src/wasm/module-compiler.cc index dbe67c9347..0f5c11005c 100644 --- a/src/wasm/module-compiler.cc +++ b/src/wasm/module-compiler.cc @@ -2326,6 +2326,14 @@ void AsyncCompileJob::AsyncCompileSucceeded(Handle result) { // the module's start function calls out to Blink. Local backup_incumbent_context = Utils::ToLocal(incumbent_context_); + // We have to enter a MicrotasksScope here, because the + // CompilationResultResolver potentially creates a Microtask below in + // {OnCompilationSucceeded}. + MicrotasksScope microtasks_scope(reinterpret_cast(isolate()), + MicrotasksScope::kRunMicrotasks); + // Enter a {CallDepthScope} explicitly, because we did not go through + // {ENTER_V8}, and otherwise MicrotasksPolicy::kAuto does not work. + CallDepthScope call_depth_scope(isolate(), backup_incumbent_context); v8::Context::BackupIncumbentScope incumbent(backup_incumbent_context); resolver_->OnCompilationSucceeded(result); }