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

node-api: fix immediate napi_remove_wrap test #45406

Merged

Commits on Nov 10, 2022

  1. node-api: fix immediate napi_remove_wrap test

    As documented in napi_wrap section, the returned reference must be
    deleted with `napi_delete_reference` in response to the finalize
    callback, in which `napi_unwrap` and `napi_remove_wrap` is not
    available.
    
    When the reference needs to be deleted early, it should be
    deleted after the wrapped value is not accessed with `napi_unwrap`
    and `napi_remove_wrap` too.
    
    This test is previously added in response to duplicating the test
    https://github.com/nodejs/node-addon-api/blob/main/test/objectwrap_constructor_exception.cc
    in the node-addon-api. As Napi::ObjectWrap<> is a subclass of
    Napi::Reference<>, napi_remove_wrap in the destructor of
    Napi::ObjectWrap<> is called before napi_delete_reference in the
    destructor of Napi::Reference<>.
    legendecas committed Nov 10, 2022
    Copy the full SHA
    098999e View commit details
    Browse the repository at this point in the history