Skip to content

Commit

Permalink
Minimal node 12 support (#62)
Browse files Browse the repository at this point in the history
* Minimal node 12 support
* Fix deprecated v8/nan calls.
  • Loading branch information
kneth authored May 18, 2019
1 parent 024ca6c commit 6c47b1f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
### NEXT

* [PR#62](https://github.com/ddopson/node-segfault-handler/pull/62) - Support for node 12.

### 1.1.0 (2018-04-30)

* [PR#37](https://github.com/ddopson/node-segfault-handler/pull/37) - Fix lack of stack trace on ARM.
* [PR#57](https://github.com/ddopson/node-segfault-handler/pull/57) - Support for Xcode 10.
* [PR#58](https://github.com/ddopson/node-segfault-handler/pull/58) - Fix the `v8::String` deprecation warning.
* [PR#58](https://github.com/ddopson/node-segfault-handler/pull/58) - Fix the `v8::String` deprecation warning.

### 1.0.1 (2018-05-17)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"bindings": "^1.2.1",
"nan": "^2.0.9"
"nan": "^2.13.2"
},
"main": "index.js",
"license": "BSD-3-Clause"
Expand Down
10 changes: 5 additions & 5 deletions src/segfault-handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct callback_helper {
uv_async_t* handle;
v8::Persistent<Function, v8::CopyablePersistentTraits<Function> > callback;

callback_helper(Handle<Function> func) {
callback_helper(Local<Function> func) {
Isolate* isolate = Isolate::GetCurrent();
// set the function reference
callback.Reset(isolate, func);
Expand Down Expand Up @@ -149,14 +149,14 @@ struct callback_helper {
// build the stack arguments
Local<Array> argStack = Array::New(isolate, args->stack_size);
for (size_t i = 0; i < args->stack_size; i++) {
argStack->Set(i, String::NewFromUtf8(isolate, args->stack[i]));
Nan::Set(argStack, i, String::NewFromUtf8(isolate, args->stack[i], v8::NewStringType::kInternalized).ToLocalChecked());
}

// collect all callback arguments
Local<Value> argv[3] = {Number::New(isolate, args->signo), Number::New(isolate, args->addr), argStack};

// execute the callback function on the main threaod
Local<Function>::New(isolate, *args->callback)->Call(isolate->GetCurrentContext()->Global(), 3, argv);
Nan::Call(Local<Function>::New(isolate, *args->callback), isolate->GetCurrentContext()->Global(), 3, argv);

// broadcast that we're done with the callback
pthread_cond_broadcast(&args->cond);
Expand Down Expand Up @@ -302,7 +302,7 @@ NAN_METHOD(RegisterHandler) {

strncpy(logPath, *utf8Value, len);
logPath[127] = '\0';

#ifndef _WIN32
} else if (info[i]->IsFunction()) {
if (callback) {
Expand All @@ -311,7 +311,7 @@ NAN_METHOD(RegisterHandler) {
}

// create the new callback object
callback = new callback_helper(Handle<Function>::Cast(info[i]));
callback = new callback_helper(Local<Function>::Cast(info[i]));
#endif

}
Expand Down

0 comments on commit 6c47b1f

Please sign in to comment.