@@ -757,8 +757,15 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
|
757 | 757 | bool timed_out = false; |
758 | 758 | bool received_signal = false; |
759 | 759 | MaybeLocal<Value> result; |
760 | | -auto run = [&]() { |
761 | | - MaybeLocal<Value> result = module->Evaluate(context); |
| 760 | + { |
| 761 | +auto wd = timeout != -1 |
| 762 | + ? std::make_optional<Watchdog>(isolate, timeout, &timed_out) |
| 763 | + : std::nullopt; |
| 764 | +auto swd = break_on_sigint ? std::make_optional<SigintWatchdog>( |
| 765 | + isolate, &received_signal) |
| 766 | + : std::nullopt; |
| 767 | + |
| 768 | + result = module->Evaluate(context); |
762 | 769 | |
763 | 770 | Local<Value> res; |
764 | 771 | if (result.ToLocal(&res) && microtask_queue) { |
@@ -792,29 +799,15 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
|
792 | 799 | Local<Context> outer_context = isolate->GetCurrentContext(); |
793 | 800 | Local<Promise::Resolver> resolver; |
794 | 801 | if (!Promise::Resolver::New(outer_context).ToLocal(&resolver)) { |
795 | | -return MaybeLocal<Value>(); |
| 802 | +result = {}; |
796 | 803 | } |
797 | 804 | if (resolver->Resolve(outer_context, res).IsNothing()) { |
798 | | -return MaybeLocal<Value>(); |
| 805 | +result = {}; |
799 | 806 | } |
800 | 807 | result = resolver->GetPromise(); |
801 | 808 | |
802 | 809 | microtask_queue->PerformCheckpoint(isolate); |
803 | 810 | } |
804 | | -return result; |
805 | | - }; |
806 | | -if (break_on_sigint && timeout != -1) { |
807 | | - Watchdog wd(isolate, timeout, &timed_out); |
808 | | - SigintWatchdog swd(isolate, &received_signal); |
809 | | - result = run(); |
810 | | - } else if (break_on_sigint) { |
811 | | - SigintWatchdog swd(isolate, &received_signal); |
812 | | - result = run(); |
813 | | - } else if (timeout != -1) { |
814 | | - Watchdog wd(isolate, timeout, &timed_out); |
815 | | - result = run(); |
816 | | - } else { |
817 | | - result = run(); |
818 | 811 | } |
819 | 812 | |
820 | 813 | if (result.IsEmpty()) { |
|