Skip to content

Commit e240ec2

Browse files
committed
fix: crash when accessing contact cache
1 parent 565da89 commit e240ec2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

contacts.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "node.h"
12
#import <AppKit/AppKit.h>
23
#import <Contacts/Contacts.h>
34
#include <napi.h>
@@ -736,6 +737,10 @@ CNAuthorizationStatus AuthStatus() {
736737
exports.Set(Napi::String::New(env, "updateContact"),
737738
Napi::Function::New(env, UpdateContact));
738739

740+
auto *isolate = v8::Isolate::GetCurrent();
741+
node::AddEnvironmentCleanupHook(
742+
isolate, [](void *) { contacts_ref.Reset(); }, isolate);
743+
739744
return exports;
740745
}
741746

0 commit comments

Comments
 (0)