Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

migrate keytar to use n-api #268

Merged
merged 1 commit into from
May 10, 2020
Merged

migrate keytar to use n-api #268

merged 1 commit into from
May 10, 2020

Conversation

jkleinsc
Copy link
Contributor

@jkleinsc jkleinsc commented May 7, 2020

This PR migrates keytar from nan to N-API via the node-addon-api module.

Migrating to N-API provides ABI stability meaning that versions of keytar compiled for one major version can run on later major versions of Node.js without recompilation. This means that issues like #174 would be non-issues in the future.

@shiftkey shiftkey self-requested a review May 7, 2020 14:19
@shiftkey shiftkey self-assigned this May 7, 2020
@shiftkey shiftkey merged commit 3682c56 into atom:master May 10, 2020
@shiftkey
Copy link
Contributor

This has been published to npm as v6.0.0-beta.0 and also as the beta label if anyone wants to test these changes.

Napi::Value DeletePassword(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
if (!info[0].IsString()) {
Napi::TypeError::New(env, "Parameter 'service' must be a string");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ThrowAsJavaScriptException missing here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to extract a method like that:

void ThrowTypeError(napi_env env, const char* message) {
    Napi::TypeError::New(env, message).ThrowAsJavaScriptException();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vadim-termius, you are right -- I missed this in the conversion. #270 will resolve this.

@vadim-termius
Copy link

Migrating to N-API provides ABI stability meaning that versions of keytar compiled for one major version can run on later major versions of Node.js without recompilation. This means that issues like #174 would be non-issues in the future.

Just saw the 6th release and remembered my latest research on this topic. According to the documentation there is no guarantee in ABI stability if the module uses API from uv.h. I see there are a few includes of this header but I didn't find usage of the related API. I think, if it is possible, it is better to remove them.

@shiftkey
Copy link
Contributor

@vadim-termius nice spot - I couldn't spot anything obviously dependent on uv.h locally so I've opened #278 to see if it's feasible to include in an update.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants