Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replacing deprecated Nan:MakeCallback with Nan::AsyncResource #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

artynet
Copy link
Contributor

@artynet artynet commented Oct 30, 2019

The replacement is safe and it is strongly advised according the new https://github.com/nodejs/nan APIs

https://github.com/nodejs/nan/blob/master/doc/node_misc.md#api_nan_asyncresource

@WeiAnAn was definitely right in making this crucial modification

@@ -104,7 +104,8 @@ void after_doing_auth(uv_work_t* req, int status) {
args[0] = Nan::New<String>(m->errorString.c_str()).ToLocalChecked();
}

Nan::MakeCallback(Nan::GetCurrentContext()->Global(), Nan::New(m->callback), 1, args);
Nan::AsyncResource *asyncResource = new Nan::AsyncResource("callback");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a clean change ... but my question is what is calling delete on asyncResource ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without delete we might have a memory leak.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you 100% sure that the new NAN APIs and node 12 won't take care of it ? do you have some sort of setup to run some tests....or at least tell me how to do it ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could test it by running the code in debug mode and with valgrind to check for memory leaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants