-
Notifications
You must be signed in to change notification settings - Fork 459
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
Async handles and Errors #233
Comments
Thanks for the test case, this will help investigate and come up with an solution. |
Believe these are related: nodejs/node#15371 |
Made some progress on the plane today. Likely needs 2 PRs. One to fix up escaping of handles when the handle is undefined and then one to add napi_throw_fatal. Managed to get the test case to throw the expected error but still have work to validate what I have makes sense and then generate tests. @fivdi thanks for the test case it was very helpful. |
This will add the function needed to get the exception to come out: nodejs/node#19337, but there is still another fix needed for the right exception to come out in this test case. I'll work on the PR for that. |
The node-addon-api module was calling escape on undefined which would fail. Instead of forcing a check in all consumers of napi_escape_handle accept undefined and simply return it as it does not need to be escaped. Refs: nodejs/node-addon-api#233
PR to address escape issue that was preventing the right exception from coming out. EDIT: Turns out this was incorrect, so ignore. |
Once the 2 PRs above land we can look at the PR to add a method in node-addon-api to be able to through an exception and validate the test case in this issue passes. |
#245 along with the earlier PR (nodejs/node#19337). Will let you get the correct exception if you use:
Next step will be to add function to throw the fatal exception with node-addon-api itself along with a test. |
@fivdi I think we'll need a test case added to the node-addon-api test suite which is pretty much what you had. Do you want to contribute a PR to add it to the test suite ? |
@mhdawson I'll give it a go. When would the test be needed? |
There is no fixed time when it would be needed, but sooner than later would be better so that we have test coverage. You can writ it using napi_fatal_exception and then can change that to the node-add-api method when its available. |
I just committed, #245. You should now be able to build the test case using napi_fatal_exception(env, e.Value()); and it should pass with the latest node-addon-api. |
@fivdi do you think you'll still get to this or should I close the issue? |
@mhdawson please close the issue |
If an exception is pending from Call Or MakeCallback on FunctionReference the return value may be nullptr. Check for a pending exception and don't try to escape in these cases. PR-URL: nodejs/node-addon-api#245 Refs: nodejs/node-addon-api#233 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
If an exception is pending from Call Or MakeCallback on FunctionReference the return value may be nullptr. Check for a pending exception and don't try to escape in these cases. PR-URL: nodejs/node-addon-api#245 Refs: nodejs/node-addon-api#233 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
If an exception is pending from Call Or MakeCallback on FunctionReference the return value may be nullptr. Check for a pending exception and don't try to escape in these cases. PR-URL: nodejs/node-addon-api#245 Refs: nodejs/node-addon-api#233 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
If an exception is pending from Call Or MakeCallback on FunctionReference the return value may be nullptr. Check for a pending exception and don't try to escape in these cases. PR-URL: nodejs/node-addon-api#245 Refs: nodejs/node-addon-api#233 Reviewed-By: Hitesh Kanwathirtha <hiteshk@microsoft.com>
Async handles can be used to "wakeup" the event loop and get a callback called from another thread. However, if the callback throws an error it doesn't appear to be possible to handle the error and have it displayed to the user.
An example of such an async handle can be seen here. This async handle is initialized to call DispatchEvent when told to do so once per second. The callback is called by DispatchEvent. If the callback throws an error what needs to be done to display the error to the user?
The text was updated successfully, but these errors were encountered: