-
Notifications
You must be signed in to change notification settings - Fork 58
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
Handle scope validation tests #180
Conversation
I am concerned that PR removes all safety checks from |
The checks are not removed, but moved to the JSValueScope to napi_env conversion. We could have them in both places but I thought that was redundant since you have to get a napi_env to do anything with a handle. I can explain in more detail when I have time later. |
The main goal of |
Yes, that is a good point about additional
For static functions that take only a So we'll check in both places, and it will a little redundant sometimes, but it is only a boolean plus an I suppose we could add a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
In the update I also added consistent public (checked) |
|
Fixes #121
libnode
. [1]JSValue
,JSValueScope
, andJSReference
to pass the tests.JSValue
instance, always use the value'sScope
member rather than the thread-local "current" scope. This allows for validation that the current and target environments (threads) are the same.JSValueScopeClosedException
(subclass ofObjectDisposedException
) andJSInvalidScopeException
(subclass ofInvalidOperationException
) to provide detailed error info when a handle scope problem is detected.JSRuntimeContext
via the hint parameter of all finalizers (which required some minor refactoring where the hint was used for other things). Previously the finalizers were getting the context via the thread-local scope, which caused errors when finalizers ran after the root scope was closed. Also the finalizers were callingnapi_get_instance_data
(many times) which should be avoided. Finalizers now do not make any JS calls and do not rely on any thread-statics.JSReference.Dispose()
, to handle disposing references after the root scope was closed.""
). This broke builds targeting .NET 4 where the--packs
argument value is empty. (I don't know how this passed testing before.)I compared benchmark results before and after the changes - there was no measurable impact from the additional validations.
[1] Currently I get a crash when trying to create more than one "environment" using the new embedding APIs. I will check whether that is fixed in a newer revision of that PR; I'm using a build of
libnode
from a much older PR revision.