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

Fix Node.js 12 support #499

Merged
merged 2 commits into from
Jul 22, 2019
Merged

Fix Node.js 12 support #499

merged 2 commits into from
Jul 22, 2019

Conversation

ilammy
Copy link
Collaborator

@ilammy ilammy commented Jul 17, 2019

Latest stable release of Node.js 12 includes updated V8 engine which has finally removed some of the deprecated API that we are using. JavaScript ecosystem has relatively low half-life periods for versions so we need to upgrade.

  • Use v8::Local instead of v8::Handle

v8::Handle has been deprecated in favor of v8::Local since V8 4.5 and has been removed somewhere after V8 7.0. Node.js 12 (current stable) is upgrading V8 engine to 7.4+ which does not support v8::Handle.

Mass-replace v8::Handle → v8::Local to avoid that issue. It's supported even by the ancient Node versions packaged in older Ubuntu releases.

  • Use NAN helpers

v8::Object::Set() and v8::FunctionTemplate::GetFunction() have had their API changed between V8 versions. Upgrading Node.js to 12 breaks them completely.

Instead of using this API directly we should be using NAN helpers that encapsulate the changes and provide common API for Maybe types.


I have manually verified these changes with the following Node.js versions:

  • Node.js v4.2.6 — packaged with Ubuntu 16 LTS (Xenial Xerus), checked by CircleCI
  • Node.js v8.16 — current maintenance LTS version of Node.js, still somewhat supported
  • Node.js v10.16 — current active LTS version of Node.js, recommended for current users
  • Node.js v12.6 — latest stable version of Node.js, in development

Currently CircleCI checks only Node.js v4. This PR does not update the build system so you'll have to trust me that it actually builds, for now.

v8::Handle has been deprecated in favor of v8::Local since V8 4.5 and
has been removed somehwere after V8 7.0. Node.js 12 (current stable)
is upgrading V8 engine to 7.4+ which does not support v8::Handle.

Mass-replace v8::Handle -> v8::Local to avoid that issue. It's supported
even by the ancient Node versions packaged in older Ubuntu releases.
v8::Object::Set() and v8::FunctionTemplate::GetFunction() have had
their API changed between V8 versions. Upgrading Node.js to 12 breaks
them completely.

Instead of using this API directly we should be using NAN helpers that
encapsulate the changes and provide common API for Maybe types.
@ilammy ilammy requested a review from vixentael July 17, 2019 15:15
@ilammy ilammy requested a review from Lagovas as a code owner July 17, 2019 15:15
@vixentael
Copy link
Contributor

This PR does not update the build system so you'll have to trust me that it actually builds, for now.

but can we add checks for different node versions to CircleCI later? or check them in BuildBot 🤔

Copy link
Contributor

@vixentael vixentael left a comment

Choose a reason for hiding this comment

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

sometimes js looks like magic

// Prepare constructor template
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(SecureCellContextImprint::New);
tpl->SetClassName(Nan::New("SecureCellContextImprint").ToLocalChecked());
tpl->SetClassName(className);
Copy link
Contributor

@vixentael vixentael Jul 17, 2019

Choose a reason for hiding this comment

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

good catch (here and below)

@ilammy
Copy link
Collaborator Author

ilammy commented Jul 18, 2019

@vixentael,

but can we add checks for different node versions to CircleCI later?

Sure thing. I'll add them, just in a separate PR.

Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

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

lgtm

@ilammy ilammy merged commit 4aecf90 into cossacklabs:master Jul 22, 2019
@ilammy ilammy deleted the node-12 branch July 22, 2019 12:45
@ilammy ilammy added W-JsThemis 🍭 Wrapper: JsThemis for Node.js, JavaScript API, npm packages and removed E-Node.js labels Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
W-JsThemis 🍭 Wrapper: JsThemis for Node.js, JavaScript API, npm packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants