Skip to content

Commit de261b9

Browse files
authored
Merge branch 'nodejs:main' into diangogav/test-tls-check-server-identity-coverage
2 parents 96e800c + f46444d commit de261b9

File tree

4 files changed

+33
-37
lines changed

4 files changed

+33
-37
lines changed

glossary.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ This file documents various terms and definitions used throughout the Node.js co
9797
* **VM**: [The Node.js VM module][] - Provides a way of executing code within V8 Virtual Machine contexts.
9898
* **W3C**: [World Wide Web Consortium][] - An international community that develops standards and guidelines for
9999
various aspects of the web ecosystem.
100-
* **WASI**: [Web Assembly System Interface][] - Interface for WebAssembly.
101-
* **WASM**: Web Assembly - Binary instruction format for a stack-based virtual machine.
100+
* **WASI**: [WebAssembly System Interface][] - Interface for WebAssembly.
101+
* **WASM**: WebAssembly - Binary instruction format for a stack-based virtual machine.
102102
* **WDYT**: What Do You Think?
103103
* **WG**: Working Group - Autonomous teams in the project with specific focus areas.
104104
* **WHATWG**: [Web Hypertext Application Technology Working Group][] - Community developing web standards.
@@ -148,8 +148,8 @@ This file documents various terms and definitions used throughout the Node.js co
148148
[Unicode Transformation Format - 8-bit]: https://en.wikipedia.org/wiki/UTF-8
149149
[Uniform Resource Locator]: https://en.wikipedia.org/wiki/URL
150150
[User Interface]: https://en.wikipedia.org/wiki/User_interface
151-
[Web Assembly System Interface]: https://github.com/WebAssembly/WASI
152151
[Web Hypertext Application Technology Working Group]: https://en.wikipedia.org/wiki/WHATWG
152+
[WebAssembly System Interface]: https://github.com/WebAssembly/WASI
153153
[World Wide Web Consortium]: https://www.w3.org/
154154
[specification document for **ECMAScript**]: https://ecma-international.org/publications-and-standards/standards/ecma-262/
155155
[web-platform-tests]: https://github.com/web-platform-tests/wpt

src/module_wrap.cc

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,15 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
757757
bool timed_out = false;
758758
bool received_signal = false;
759759
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);
762769

763770
Local<Value> res;
764771
if (result.ToLocal(&res) && microtask_queue) {
@@ -792,29 +799,15 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
792799
Local<Context> outer_context = isolate->GetCurrentContext();
793800
Local<Promise::Resolver> resolver;
794801
if (!Promise::Resolver::New(outer_context).ToLocal(&resolver)) {
795-
return MaybeLocal<Value>();
802+
result = {};
796803
}
797804
if (resolver->Resolve(outer_context, res).IsNothing()) {
798-
return MaybeLocal<Value>();
805+
result = {};
799806
}
800807
result = resolver->GetPromise();
801808

802809
microtask_queue->PerformCheckpoint(isolate);
803810
}
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();
818811
}
819812

820813
if (result.IsEmpty()) {

src/node_contextify.cc

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,24 +1296,17 @@ bool ContextifyScript::EvalMachine(Local<Context> context,
12961296
MaybeLocal<Value> result;
12971297
bool timed_out = false;
12981298
bool received_signal = false;
1299-
auto run = [&]() {
1300-
MaybeLocal<Value> result = script->Run(context);
1299+
{
1300+
auto wd = timeout != -1 ? std::make_optional<Watchdog>(
1301+
env->isolate(), timeout, &timed_out)
1302+
: std::nullopt;
1303+
auto swd = break_on_sigint ? std::make_optional<SigintWatchdog>(
1304+
env->isolate(), &received_signal)
1305+
: std::nullopt;
1306+
1307+
result = script->Run(context);
13011308
if (!result.IsEmpty() && mtask_queue != nullptr)
13021309
mtask_queue->PerformCheckpoint(env->isolate());
1303-
return result;
1304-
};
1305-
if (break_on_sigint && timeout != -1) {
1306-
Watchdog wd(env->isolate(), timeout, &timed_out);
1307-
SigintWatchdog swd(env->isolate(), &received_signal);
1308-
result = run();
1309-
} else if (break_on_sigint) {
1310-
SigintWatchdog swd(env->isolate(), &received_signal);
1311-
result = run();
1312-
} else if (timeout != -1) {
1313-
Watchdog wd(env->isolate(), timeout, &timed_out);
1314-
result = run();
1315-
} else {
1316-
result = run();
13171310
}
13181311

13191312
// Convert the termination exception into a regular exception.

src/node_watchdog.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class Watchdog {
5151
v8::Isolate* isolate() { return isolate_; }
5252

5353
private:
54+
Watchdog(const Watchdog&) = delete;
55+
Watchdog& operator=(const Watchdog&) = delete;
56+
Watchdog(Watchdog&&) = delete;
57+
Watchdog& operator=(Watchdog&&) = delete;
58+
5459
static void Run(void* arg);
5560
static void Timer(uv_timer_t* timer);
5661

@@ -77,6 +82,11 @@ class SigintWatchdog : public SigintWatchdogBase {
7782
SignalPropagation HandleSigint() override;
7883

7984
private:
85+
SigintWatchdog(const SigintWatchdog&) = delete;
86+
SigintWatchdog& operator=(const SigintWatchdog&) = delete;
87+
SigintWatchdog(SigintWatchdog&&) = delete;
88+
SigintWatchdog& operator=(SigintWatchdog&&) = delete;
89+
8090
v8::Isolate* isolate_;
8191
bool* received_signal_;
8292
};

0 commit comments

Comments
 (0)