Skip to content

Commit 24985fe

Browse files
committed
🦄 refactor: Updated Node.js to new process initialization and teardown functions
* node::InitializeOncePerProcess() * node::TearDownOncePerProcess()
1 parent 34c4e47 commit 24985fe

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

‎cpp/jni/javet_native.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ namespace Javet {
115115
if (!jniEnv->CallStaticBooleanMethod(jclassV8Host, jmethodIDV8HostIsLibraryReloadable)) {
116116
v8::V8::Dispose();
117117
v8::V8::DisposePlatform();
118+
#ifdef ENABLE_NODE
119+
node::TearDownOncePerProcess();
120+
#endif
118121
GlobalV8Platform.reset();
119122
#ifndef ENABLE_NODE
120123
GlobalV8ArrayBufferAllocator.reset();
@@ -143,18 +146,19 @@ namespace Javet {
143146
#ifdef ENABLE_NODE
144147
uv_setup_args(0, nullptr);
145148
std::vector<std::string> args{ DEFAULT_SCRIPT_NAME };
146-
std::vector<std::string> execArgs;
147-
std::vector<std::string> errors;
148149
auto flags = static_cast<node::ProcessInitializationFlags::Flags>(
149150
node::ProcessInitializationFlags::kNoFlags
150151
| node::ProcessInitializationFlags::kNoStdioInitialization
151152
| node::ProcessInitializationFlags::kNoDefaultSignalHandling
152153
| node::ProcessInitializationFlags::kNoInitializeV8
153154
| node::ProcessInitializationFlags::kNoInitializeNodeV8Platform
155+
#ifndef ENABLE_I18N
156+
| node::ProcessInitializationFlags::kNoICU
157+
#endif
154158
| node::ProcessInitializationFlags::kNoInitializeCppgc);
155-
int exitCode = node::InitializeNodeWithArgs(&args, &execArgs, &errors, flags);
156-
if (exitCode != 0) {
157-
LOG_ERROR("Failed to call node::InitializeNodeWithArgs().");
159+
std::unique_ptr<node::InitializationResult> result = node::InitializeOncePerProcess(args, flags);
160+
if (result->exit_code() != 0) {
161+
LOG_ERROR("Failed to call node::InitializeOncePerProcess().");
158162
}
159163
Javet::V8Native::GlobalV8Platform = node::MultiIsolatePlatform::Create(4);
160164
#else
@@ -174,7 +178,7 @@ namespace Javet {
174178
}
175179
#endif
176180
LOG_INFO("V8::Initialize() ends.");
181+
}
177182
}
178183
}
179-
}
180184

‎docs/release_notes/release_notes_3_1.rst

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Release Notes 3.1.x
33
===================
44

5+
3.1.1 V8 v12.4
6+
--------------
7+
8+
* Updated Node.js to new process initialization and teardown functions
9+
510
3.1.0 V8 v12.3
611
--------------
712

0 commit comments

Comments
 (0)