-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
n-api: add napi_detach_arraybuffer
#29768
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the error handling is inconsistent with the rest of N-API.
It looks like several inconsistencies have crept into how we handle errors in N-API 😕 Although it's too late to say this now, I don't believe N-API should itself throw on error. We should leave that option up to the caller. I believe it is sufficient to return |
In this PR we also have the option of adding one or more new |
Furthermore, if we do decide to throw, IMO we should return |
Can we please call the function |
1000a3e
to
96dd798
Compare
napi_arraybuffer_detach
napi_detach_arraybuffer
@gabrielschulhof Is there any suggestion on distinguishing I noticed that |
96dd798
to
415c8c7
Compare
I'd agree with @gabrielschulhof that we should avoid throwing |
415c8c7
to
51742d4
Compare
Just updated the patch to add two new napi_status and prevent from throwing:
Also since if an internal storage arraybuffer is detachable was not defined in ECMA spec, I've added a note in the document that requiring an external arraybuffer to be detached is an engine-specific behavior. |
Anyway to get this backported to 10? We need this is our libsodium bindings, to deallocate secure memory safely. |
@mafintosh it seems very fortunate that v10 maintenance start date has been delayed to 2020-05-19. I'm willing to seek to land this patch on v10. |
@legendecas ah massive thanks! really appreciate it. If we can help somehow let me know. |
As ArrayBuffer#detach is an ecma spec operation ([Section 24.1.1.3](https://tc39.es/ecma262/#sec-detacharraybuffer)), it might be good to have it in N-API. Fixes nodejs#29674 PR-URL: nodejs#29768 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
As ArrayBuffer#detach is an ecma spec operation ([Section 24.1.1.3](https://tc39.es/ecma262/#sec-detacharraybuffer)), it might be good to have it in N-API. Fixes: #29674 PR-URL: #29768 Backport-PR-URL: #33061 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
Refs: nodejs/node#29768 Refs: nodejs/node#30613 PR-URL: #659 Refs: nodejs/node#29768 Refs: nodejs/node#30613 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
Refs: nodejs/node#29768 Refs: nodejs/node#30613 PR-URL: nodejs#659 Refs: nodejs/node#29768 Refs: nodejs/node#30613 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
Refs: nodejs/node#29768 Refs: nodejs/node#30613 PR-URL: nodejs/node-addon-api#659 Refs: nodejs/node#29768 Refs: nodejs/node#30613 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
Refs: nodejs/node#29768 Refs: nodejs/node#30613 PR-URL: nodejs/node-addon-api#659 Refs: nodejs/node#29768 Refs: nodejs/node#30613 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
Refs: nodejs/node#29768 Refs: nodejs/node#30613 PR-URL: nodejs/node-addon-api#659 Refs: nodejs/node#29768 Refs: nodejs/node#30613 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
Refs: nodejs/node#29768 Refs: nodejs/node#30613 PR-URL: nodejs/node-addon-api#659 Refs: nodejs/node#29768 Refs: nodejs/node#30613 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]>
As ArrayBuffer#detach is an ecma spec operation (Section 24.1.1.3), it might be good to have it in N-API.
Fixes #29674
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes