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

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

Closed
westlakem opened this issue Aug 17, 2022 · 2 comments · Fixed by #1210
Labels

Comments

@westlakem
Copy link

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

@legendecas
Copy link
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.

@legendecas legendecas added the doc label Sep 16, 2022
@mhdawson
Copy link
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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants