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

Misplaced return in NAPI_CALL example? #49311

Closed
misterfish opened this issue Aug 24, 2023 · 2 comments · Fixed by #49395
Closed

Misplaced return in NAPI_CALL example? #49311

misterfish opened this issue Aug 24, 2023 · 2 comments · Fixed by #49395
Labels
doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API.

Comments

@misterfish
Copy link

Affected URL(s)

https://nodejs.org/api/n-api.html#usage

Description of the problem

Shouldn't return NULL be moved outside of the if block in the NAPI_CALL macro? Like this:

if (!is_pending) {                                          \
  ...                                                       \
  napi_throw_error((env), NULL, message);                   \
  /* return NULL;  */                                       \
}                                                           \
return NULL;                                                \

Otherwise the user's function will continue and may result in more napi calls.

@misterfish misterfish added the doc Issues and PRs related to the documentations. label Aug 24, 2023
@tniessen tniessen added the node-api Issues and PRs related to the Node-API. label Aug 28, 2023
@tniessen
Copy link
Member

cc @nodejs/node-api

@legendecas
Copy link
Member

Thanks for raising the issue. I believe you are right on this that the return statement is misplaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. node-api Issues and PRs related to the Node-API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants