fix: properly free IsolateData in node_main (#20446)

This commit is contained in:
Shelley Vohr 2019-10-08 09:03:04 +02:00 committed by GitHub
parent c85648a8a1
commit 8d9ba87e05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -79,9 +79,14 @@ int NodeMain(int argc, char* argv[]) {
// Initialize gin::IsolateHolder.
JavascriptEnvironment gin_env(loop);
node::Environment* env = node::CreateEnvironment(
node::CreateIsolateData(gin_env.isolate(), loop, gin_env.platform()),
gin_env.context(), argc, argv, exec_argc, exec_argv, false);
node::IsolateData* isolate_data =
node::CreateIsolateData(gin_env.isolate(), loop, gin_env.platform());
CHECK_NE(nullptr, isolate_data);
node::Environment* env =
node::CreateEnvironment(isolate_data, gin_env.context(), argc, argv,
exec_argc, exec_argv, false);
CHECK_NE(nullptr, env);
// Enable support for v8 inspector.
NodeDebugger node_debugger(env);
@ -135,6 +140,7 @@ int NodeMain(int argc, char* argv[]) {
v8::Isolate* isolate = env->isolate();
node::FreeEnvironment(env);
node::FreeIsolateData(isolate_data);
gin_env.platform()->DrainTasks(isolate);
gin_env.platform()->CancelPendingDelayedTasks(isolate);