Skip to content

Make sure wrapcallback is used#762

Closed
gabrielschulhof wants to merge 2 commits into
nodejs:masterfrom
gabrielschulhof:make-sure-wrapcallback-is-used
Closed

Make sure wrapcallback is used#762
gabrielschulhof wants to merge 2 commits into
nodejs:masterfrom
gabrielschulhof:make-sure-wrapcallback-is-used

Conversation

@gabrielschulhof
Copy link
Copy Markdown
Contributor

Finalizers are also able to call JS code and therefore throw. Thus, when calling the user's finalizer, we should wrap it in our C++-to-JS-exception converter.

Copy link
Copy Markdown
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, @gabrielschulhof I assume the extra overhead of another call is not going to be significant as finalization is not too common?

@gabrielschulhof
Copy link
Copy Markdown
Contributor Author

@mhdawson it should be inlined.

@mhdawson
Copy link
Copy Markdown
Member

mhdawson commented Jul 9, 2020

@gabrielschulhof I assume you mean by the compiler, if so that makes sense as I see you have it marked as inline

@gabrielschulhof
Copy link
Copy Markdown
Contributor Author

@mhdawson, yeah, sorry, I meant by the compiler.

@gabrielschulhof
Copy link
Copy Markdown
Contributor Author

I believe this is blocked by #773.

@gabrielschulhof
Copy link
Copy Markdown
Contributor Author

Rebased on top of #773. I had to change the child process to examine the exception in the process' uncaughtException handler because it cannot be caught otherwise since nodejs/node#34386.

@gabrielschulhof gabrielschulhof force-pushed the make-sure-wrapcallback-is-used branch from c1cdb39 to db0af19 Compare July 30, 2020 19:00
Copy link
Copy Markdown
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

gabrielschulhof pushed a commit that referenced this pull request Aug 6, 2020
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: #762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
@gabrielschulhof
Copy link
Copy Markdown
Contributor Author

Landed in cec2c76.

@gabrielschulhof gabrielschulhof deleted the make-sure-wrapcallback-is-used branch August 6, 2020 17:31
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: nodejs/node-addon-api#762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: nodejs/node-addon-api#762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: nodejs/node-addon-api#762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
Make sure C++ exceptions thrown from a finalizer are converted into
JS exceptions just as they are in regular callbacks.

Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
PR-URL: nodejs/node-addon-api#762
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>

test: add finalizer exception test

src: wrap finalizer callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants