diff --git a/native_mate/function_template.h b/native_mate/function_template.h index 0a607c0..4d34739 100644 --- a/native_mate/function_template.h +++ b/native_mate/function_template.h @@ -185,6 +185,8 @@ class Invoker, ArgTypes...> template void DispatchToCallback(base::Callback callback) { + v8::MicrotasksScope script_scope( + args_->isolate(), v8::MicrotasksScope::kRunMicrotasks); args_->Return(callback.Run(ArgumentHolder::value...)); } @@ -192,6 +194,8 @@ class Invoker, ArgTypes...> // expression to foo. As a result, we must specialize the case of Callbacks // that have the void return type. void DispatchToCallback(base::Callback callback) { + v8::MicrotasksScope script_scope( + args_->isolate(), v8::MicrotasksScope::kRunMicrotasks); callback.Run(ArgumentHolder::value...); }