From 392576167f2abdfb19cccd5fedb22a5c87fd93b1 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Fri, 23 Feb 2018 13:17:13 +0500 Subject: [PATCH 1/2] fix: propagate async context Start with Nan 2.9.0 certain varaiants of Nan::Callback::Call are deprecated. Overloads that preserve the async context are preferred instead. We associate a Nan::AsyncResource corresponding to a FSEvents instance. This captures the async execution context which is restored when the async callback is called. For more information see https://github.com/nodejs/nan/blob/HEAD/doc/node_misc.md#nanasyncresource. --- fsevents.cc | 4 +++- package.json | 2 +- src/methods.cc | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fsevents.cc b/fsevents.cc index a347db1..42f2f69 100644 --- a/fsevents.cc +++ b/fsevents.cc @@ -41,6 +41,7 @@ namespace fse { void threadStop(); // methods.cc - internal + Nan::AsyncResource async_resource; Nan::Callback *handler; void emitEvent(const char *path, UInt32 flags, UInt64 id); @@ -59,7 +60,8 @@ namespace fse { using namespace fse; -FSEvents::FSEvents(const char *path, Nan::Callback *handler): handler(handler) { +FSEvents::FSEvents(const char *path, Nan::Callback *handler) + : async_resource("fsevents:FSEvents"), handler(handler) { CFStringRef dirs[] = { CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8) }; paths = CFArrayCreate(NULL, (const void **)&dirs, 1, NULL); threadloop = NULL; diff --git a/package.json b/package.json index c2a81ed..f000167 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Native Access to Mac OS-X FSEvents", "main": "fsevents.js", "dependencies": { - "nan": "^2.3.0", + "nan": "^2.9.2", "node-pre-gyp": "^0.6.39" }, "os": [ diff --git a/src/methods.cc b/src/methods.cc index 976c959..97ac2d2 100644 --- a/src/methods.cc +++ b/src/methods.cc @@ -11,7 +11,7 @@ void FSEvents::emitEvent(const char *path, UInt32 flags, UInt64 id) { Nan::New(flags), Nan::New(id) }; - handler->Call(3, argv); + handler->Call(3, argv, &async_resource); } NAN_METHOD(FSEvents::New) { From 34da631b8b972446ee987f3001c7336a62235e48 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Sat, 24 Feb 2018 09:51:50 +0500 Subject: [PATCH 2/2] stop building against Node 0.12 With new enough compilers, V8 headers corresponding to 0.12 no longer compile. For more details see https://github.com/nodejs/nan#compiling-against-nodejs-012-on-osx --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bc48ed2..07d2e64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,6 @@ env: - NODE_VERSION="v6" - NODE_VERSION="v5" - NODE_VERSION="v4" - - NODE_VERSION="v0.12" - NODE_VERSION="v0.10" before_install: