getdns-node
getdns-node copied to clipboard
Fix deprecated NAN async callback usage
Deprecation warnings (since Node.js v10):
Nan::MakeCallback(...)Call(...)onNan::Callback
Should either use/pass in Nan::AsyncResource, or switch to Nan::AsyncWorker (which builds upon Nan::AsyncResource).
The effect on asynchronous DNS requests should be assessed, and possibly improved. This change may help with cleanup of both finished and unfinished requests.
See
- https://travis-ci.org/github/getdnsapi/getdns-node/jobs/769298461#L309-L393
- https://github.com/nodejs/nan
- https://github.com/nodejs/nan/blob/master/doc/node_misc.md#nanmakecallback
- https://github.com/nodejs/nan/blob/master/doc/node_misc.md#api_nan_asyncresource
- https://github.com/nodejs/nan/blob/master/doc/asyncworker.md#api_nan_async_worker
../src/GNContext.cpp: In static member function ‘static void GNContext::Callback(getdns_context*, getdns_callback_type_t, getdns_dict*, void*, getdns_transaction_t)’:
../src/GNContext.cpp:832:69: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(v8::Local<v8::Object>, int, v8::Local<v8::Value>*) const’ is deprecated [-Wdeprecated-declarations]
832 | data->callback->Call(Nan::GetCurrentContext()->Global(), 3, argv);
| ^
In file included from ../src/GNContext.h:32,
from ../src/GNContext.cpp:28:
../node_modules/nan/nan.h:1720:3: note: declared here
1720 | Call(v8::Local<v8::Object> target
| ^~~~
../src/GNContext.cpp: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE GNContext::Lookup(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/GNContext.cpp:877:81: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
877 | Nan::MakeCallback(Nan::GetCurrentContext()->Global(), localCb, 1, cbArgs);
| ^
In file included from ../src/GNContext.h:32,
from ../src/GNContext.cpp:28:
../node_modules/nan/nan.h:1026:46: note: declared here
1026 | NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
| ^~~~~~~~~~~~
../src/GNContext.cpp:886:81: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
886 | Nan::MakeCallback(Nan::GetCurrentContext()->Global(), localCb, 1, cbArgs);
| ^
In file included from ../src/GNContext.h:32,
from ../src/GNContext.cpp:28:
../node_modules/nan/nan.h:1026:46: note: declared here
1026 | NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
| ^~~~~~~~~~~~
../src/GNContext.cpp:916:81: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
916 | Nan::MakeCallback(Nan::GetCurrentContext()->Global(), localCb, 1, cbArgs);
| ^
In file included from ../src/GNContext.h:32,
from ../src/GNContext.cpp:28:
../node_modules/nan/nan.h:1026:46: note: declared here
1026 | NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
| ^~~~~~~~~~~~
../src/GNContext.cpp: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE GNContext::HelperLookup(Nan::NAN_METHOD_ARGS_TYPE)’:
../src/GNContext.cpp:992:81: warning: ‘v8::Local<v8::Value> Nan::MakeCallback(v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*)’ is deprecated [-Wdeprecated-declarations]
992 | Nan::MakeCallback(Nan::GetCurrentContext()->Global(), localCb, 1, cbArgs);
| ^
In file included from ../src/GNContext.h:32,
from ../src/GNContext.cpp:28:
../node_modules/nan/nan.h:1026:46: note: declared here
1026 | NAN_DEPRECATED inline v8::Local<v8::Value> MakeCallback(
| ^~~~~~~~~~~~
In file included from ../src/GNContext.h:31,
from ../src/GNContext.cpp:28:
../src/GNContext.cpp: At global scope: