Skip to content

Commit 498b061

Browse files
committed
Upgrade nan dependency, enables async hooks
1 parent 5ab6f59 commit 498b061

4 files changed

Lines changed: 16 additions & 12 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"dependencies": {
7979
"color": "^3.0.0",
8080
"detect-libc": "^1.0.3",
81-
"nan": "^2.8.0",
81+
"nan": "^2.9.2",
8282
"semver": "^5.5.0",
8383
"simple-get": "^2.7.0",
8484
"tar": "^4.3.2",

src/metadata.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class MetadataWorker : public Nan::AsyncWorker {
2727
MetadataWorker(
2828
Nan::Callback *callback, MetadataBaton *baton, Nan::Callback *debuglog,
2929
std::vector<v8::Local<v8::Object>> const buffersToPersist) :
30-
Nan::AsyncWorker(callback), baton(baton), debuglog(debuglog),
30+
Nan::AsyncWorker(callback, "sharp:MetadataWorker"),
31+
baton(baton), debuglog(debuglog),
3132
buffersToPersist(buffersToPersist) {
3233
// Protect Buffer objects from GC, keyed on index
3334
std::accumulate(buffersToPersist.begin(), buffersToPersist.end(), 0,
@@ -165,12 +166,12 @@ class MetadataWorker : public Nan::AsyncWorker {
165166
std::string warning = sharp::VipsWarningPop();
166167
while (!warning.empty()) {
167168
v8::Local<v8::Value> message[1] = { New(warning).ToLocalChecked() };
168-
debuglog->Call(1, message);
169+
debuglog->Call(1, message, async_resource);
169170
warning = sharp::VipsWarningPop();
170171
}
171172

172173
// Return to JavaScript
173-
callback->Call(2, argv);
174+
callback->Call(2, argv, async_resource);
174175
}
175176

176177
private:

src/pipeline.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class PipelineWorker : public Nan::AsyncWorker {
3535
PipelineWorker(
3636
Nan::Callback *callback, PipelineBaton *baton, Nan::Callback *debuglog, Nan::Callback *queueListener,
3737
std::vector<v8::Local<v8::Object>> const buffersToPersist) :
38-
Nan::AsyncWorker(callback), baton(baton), debuglog(debuglog), queueListener(queueListener),
38+
Nan::AsyncWorker(callback, "sharp:PipelineWorker"),
39+
baton(baton), debuglog(debuglog), queueListener(queueListener),
3940
buffersToPersist(buffersToPersist) {
4041
// Protect Buffer objects from GC, keyed on index
4142
std::accumulate(buffersToPersist.begin(), buffersToPersist.end(), 0,
@@ -1014,18 +1015,18 @@ class PipelineWorker : public Nan::AsyncWorker {
10141015
std::string warning = sharp::VipsWarningPop();
10151016
while (!warning.empty()) {
10161017
v8::Local<v8::Value> message[1] = { New(warning).ToLocalChecked() };
1017-
debuglog->Call(1, message);
1018+
debuglog->Call(1, message, async_resource);
10181019
warning = sharp::VipsWarningPop();
10191020
}
10201021

10211022
// Decrement processing task counter
10221023
g_atomic_int_dec_and_test(&sharp::counterProcess);
10231024
v8::Local<v8::Value> queueLength[1] = { New<v8::Uint32>(sharp::counterQueue) };
1024-
queueListener->Call(1, queueLength);
1025+
queueListener->Call(1, queueLength, async_resource);
10251026
delete queueListener;
10261027

10271028
// Return to JavaScript
1028-
callback->Call(3, argv);
1029+
callback->Call(3, argv, async_resource);
10291030
}
10301031

10311032
private:
@@ -1302,5 +1303,6 @@ NAN_METHOD(pipeline) {
13021303
// Increment queued task counter
13031304
g_atomic_int_inc(&sharp::counterQueue);
13041305
v8::Local<v8::Value> queueLength[1] = { Nan::New<v8::Uint32>(sharp::counterQueue) };
1305-
queueListener->Call(1, queueLength);
1306+
v8::Local<v8::Object> recv = Nan::New<v8::Object>();
1307+
Nan::Call(*queueListener, recv, 1, queueLength);
13061308
}

src/stats.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class StatsWorker : public Nan::AsyncWorker {
2828
StatsWorker(
2929
Nan::Callback *callback, StatsBaton *baton, Nan::Callback *debuglog,
3030
std::vector<v8::Local<v8::Object>> const buffersToPersist) :
31-
Nan::AsyncWorker(callback), baton(baton), debuglog(debuglog),
31+
Nan::AsyncWorker(callback, "sharp:StatsWorker"),
32+
baton(baton), debuglog(debuglog),
3233
buffersToPersist(buffersToPersist) {
3334
// Protect Buffer objects from GC, keyed on index
3435
std::accumulate(buffersToPersist.begin(), buffersToPersist.end(), 0,
@@ -145,12 +146,12 @@ class StatsWorker : public Nan::AsyncWorker {
145146
std::string warning = sharp::VipsWarningPop();
146147
while (!warning.empty()) {
147148
v8::Local<v8::Value> message[1] = { New(warning).ToLocalChecked() };
148-
debuglog->Call(1, message);
149+
debuglog->Call(1, message, async_resource);
149150
warning = sharp::VipsWarningPop();
150151
}
151152

152153
// Return to JavaScript
153-
callback->Call(2, argv);
154+
callback->Call(2, argv, async_resource);
154155
}
155156

156157
private:

0 commit comments

Comments
 (0)