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

tsfn: add error checking on GetContext #583

Merged
merged 3 commits into from
Nov 18, 2019

Conversation

KevinEady
Copy link
Contributor

Fixes: #581

@KevinEady
Copy link
Contributor Author

node-addon-api/napi-inl.h

Lines 4113 to 4114 in e142a1e

napi_status status = napi_get_threadsafe_function_context(*_tsfn, &context);
NAPI_FATAL_IF_FAILED(status, "ThreadSafeFunction::GetContext", "napi_get_threadsafe_function_context");

Will need to review if FATAL error is correct. If not, how to properly handle this error

Object::New(env), "Test", 1, 1, _ctx,
[this](Napi::Env env, Reference<Napi::Value> *ctx) {
_deferred->Resolve(env.Undefined());
_deferred.reset();
Copy link
Member

Choose a reason for hiding this comment

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

I don't think reset is necessary here as the unique ptr would call the deleter on destruct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 will update in later push, when master is updated with #583 since this PR conflicts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@KevinEady
Copy link
Contributor Author

Hey @mhdawson / @gabrielschulhof ,

On the same basis of #566 (see #566 (comment)) , would this also be considered SemVer major? If so, should we put this in to the 2.0.0 release (the scope seems to be ever increasing...)

In this case, "should not affect any code": If you were using GetContext() after an error and you still used the resulting Context* pointer, you'd probably crash with an error anyway?

This PR also directly conflicts with #580 because of the modifications of the test files, and as 580 is higher prio, I can't update this until that PR is merged.

@NickNaso NickNaso mentioned this pull request Nov 15, 2019
15 tasks
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM after update based on comment in ThreadSafeFunction::New

@mhdawson
Copy link
Member

@KevinEady do you know when you will be able to push the change to address the outstanding comment?

@KevinEady
Copy link
Contributor Author

Hi @mhdawson , just pushed!

@mhdawson mhdawson merged commit c881168 into nodejs:master Nov 18, 2019
@mhdawson
Copy link
Member

Landed as c881168

kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
 PR-URL: nodejs/node-addon-api#583
 Reviewed-By: Michael Dawson <[email protected]>
 Reviewed-By: Chengzhong Wu <[email protected]>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
 PR-URL: nodejs/node-addon-api#583
 Reviewed-By: Michael Dawson <[email protected]>
 Reviewed-By: Chengzhong Wu <[email protected]>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
 PR-URL: nodejs/node-addon-api#583
 Reviewed-By: Michael Dawson <[email protected]>
 Reviewed-By: Chengzhong Wu <[email protected]>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
 PR-URL: nodejs/node-addon-api#583
 Reviewed-By: Michael Dawson <[email protected]>
 Reviewed-By: Chengzhong Wu <[email protected]>
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.

Error was ignored if ThreadSafeFunction::GetContext() failed
3 participants