File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,17 @@ void SetNodeCliFlags() {
74
74
ProcessGlobalArgs (&args, nullptr , &errors, node::kDisallowedInEnvironment );
75
75
}
76
76
77
+ // TODO(codebytere): expose this from Node.js itself?
78
+ void HostCleanupFinalizationGroupCallback (
79
+ v8::Local<v8::Context> context,
80
+ v8::Local<v8::FinalizationGroup> group) {
81
+ node::Environment* env = node::Environment::GetCurrent (context);
82
+ if (env == nullptr ) {
83
+ return ;
84
+ }
85
+ env->RegisterFinalizationGroupForCleanup (group);
86
+ }
87
+
77
88
} // namespace
78
89
79
90
namespace electron {
@@ -143,6 +154,10 @@ int NodeMain(int argc, char* argv[]) {
143
154
node::BootstrapEnvironment (env);
144
155
env->InitializeDiagnostics ();
145
156
157
+ // This is needed in order to enable v8 host weakref hooks.
158
+ gin_env.isolate ()->SetHostCleanupFinalizationGroupCallback (
159
+ HostCleanupFinalizationGroupCallback);
160
+
146
161
gin_helper::Dictionary process (gin_env.isolate (), env->process_object ());
147
162
#if defined(OS_WIN)
148
163
process.SetMethod (" log" , &ElectronBindings::Log);
You can’t perform that action at this time.
0 commit comments