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 |
|
In the update I also added consistent public (checked) |
|
Fixes #121
libnode. [1]JSValue,JSValueScope, andJSReferenceto pass the tests.JSValueinstance, always use the value'sScopemember 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.JSRuntimeContextvia 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--packsargument 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
libnodefrom a much older PR revision.