Skip to content

Napi::HandleScope::HandleScope(const Napi::HandleScope &)cannot be referenced -- it is a deleted function #1197

Closed

Description

@westlakem

Disclamer: I know very little about C++.

When trying to convert an open source project from NAN to napi, I'm getting the following error when trying to ref a HandleScope object.

function "Napi::HandleScope::HandleScope(const Napi::HandleScope &)" (declared at line 2269 of "D:\devl\js\fsuipc-node\node_modules\node-addon-api\napi.h") cannot be referenced -- it is a deleted function

converting
Nan::HandleScope scope;
to
Napi::HandleScope::HandleScope(Napi::Env env);
as referenced https://github.com/nodejs/node-addon-api/blob/main/doc/handle_scope.md

Activity

  1. legendecas commented on Sep 16, 2022

    @legendecas
    Member

    You should be able to create a handle scope with a similar pattern in NAN:

    // 'env' is a 'Napi::Env';
    Napi::HandleScope scope(env);
    

    The pattern in the document shows the declaration of the Napi::HandleScope constructor. It is not meant to be constructed in that way.

    I believe we need an example in the HandleScope documentation.

  2. mhdawson commented on Sep 16, 2022

    @mhdawson
    Member

    @KevinEady will take a look at updating the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions