-
Notifications
You must be signed in to change notification settings - Fork 504
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 deprecation warnings on node 10.12 #811
Fix deprecation warnings on node 10.12 #811
Conversation
I started out trying to make this based on |
@addaleax Is there a better way to detect support for the new APIs? |
node commit: nodejs/node@46c7d0d Fixes nodejs#810
44eaa1c
to
d63a550
Compare
That seems a bit fishy. Was there some |
Afaict it was introduced in the node commit linked above. It's a patch on top of V8 floated by node if I'm reading it correctly. |
Ah, that explains it. I must have missed the commit link. |
@jkrems I think this is fine – |
Totally possible. I got lazy once I finally found a working guard for the |
If I understand this change correct it turns compilation warnings into incompatibility. |
That’s correct, yes; but only for the |
But then the ifdefs should be adapted to select the new APIs for all node 10 versions. |
@@ -334,7 +334,7 @@ Factory<v8::String>::New(ExternalOneByteStringResource * value) { | |||
|
|||
Factory<v8::StringObject>::return_t | |||
Factory<v8::StringObject>::New(v8::Local<v8::String> value) { | |||
#if V8_MAJOR_VERSION >= 7 | |||
#if V8_MAJOR_VERSION >= 7 || defined(NAN_HAS_V8_7_DEPRECATIONS) | |||
return v8::StringObject::New(v8::Isolate::GetCurrent(), value).As<v8::StringObject>(); |
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.
Ai, I raised this in nodejs/node#23159 (comment) - it means you can't distribute a pre-compiled add-on and have it work with older Node.js v10.x releases. That seems bad. Maybe we should just accept this warning as unavoidable.
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.
Well, for me it would mean that I would drop nan in my project. Because I know what lengths some of the users inside of Groupon will go to if they try to "fix" the warnings unfortunately. :(
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.
it means you can't distribute a pre-compiled add-on and have it work with older Node.js v10.x releases.
As you mentioned in your linked comment – this would only affect people who actually use StringObject::New()
, of which there aren’t many to begin with, right?
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.
No, I haven't seen it used much. Small consolation if you're one of the unhappy few, though.
I've cobbled up this monstrosity: #pragma warning(push)
#pragma warning(disable : 4996)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#include "nan.h"
#pragma clang diagnostic pop
#pragma GCC diagnostic pop
#pragma warning(pop) and this to 'defines': [ '-Wno-unknown-pragmas', ], So at least you don't get warning on the declarations. or You could add this to your 'defines': [ '-Wno-deprecated-declarations', ], |
For now I'll go with something like this:
Not really windows compatible but allows seeing deprecations in verbose mode while not leaking them into |
Unless there's a way to fix this without breaking compatibility - should this PR be closed? |
For windows comapt add 'msvs_disabled_warnings': [4996], like: "conditions": [
[
'"<!(echo $V)" != "1"',
{
"cflags": [
"-Wno-deprecated-declarations",
],
"xcode_settings": {
"OTHER_CFLAGS": [
"-Wno-deprecated-declarations",
],
},
'msvs_disabled_warnings': [4996],
},
],
], |
@@ -1060,8 +1064,9 @@ class Utf8String { | |||
length_(0), str_(str_st_) { | |||
HandleScope scope; | |||
if (!from.IsEmpty()) { | |||
#if V8_MAJOR_VERSION >= 7 | |||
v8::Local<v8::String> string = from->ToString(v8::Isolate::GetCurrent()); | |||
#if V8_MAJOR_VERSION >= 7 || defined(NAN_HAS_V8_7_DEPRECATIONS) |
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.
You could use #if NODE_MODULE_VERSION >= NODE_10_0_MODULE_VERSION
to use the same API independent of the minor node version.
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 thought I checked the node module version and it didn't change between these two versions unless I'm missing something here? It might be possible for the cases where the new API already existed but there's many solutions for those. :)
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.
The new variants of ToString()
and WriteUtf8()
are available already in 10.0.0 (or even before) only the StringObject
is problematic as the new variant is only available since 10.12.0.
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.
Yeah, exactly. :) But see above - I haven't updated this PR yet because there didn't seem to be agreement on how the real problem (the 3rd API) should be solved. I'm not a huge fan of churn when there's no clear target.
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.
Ah ok. My understanding was the agreement is that users of StringObject
via NAN have bad luck if they have to distribute precompiled binaries.
But maybe you are right and we should give this some more time and votes.
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.
Since nobody saw it fit to increase the module version when rolling out breaking changes in a minor update and there is no nice way of resolving the issue, I'd say it is not our problem. NAN never promised ABI compatibility, Node says the ABI has not changed, bug reports go upstream and in time this will be a footnote in history.
@@ -1074,7 +1079,7 @@ class Utf8String { | |||
} | |||
const int flags = | |||
v8::String::NO_NULL_TERMINATION | imp::kReplaceInvalidUtf8; | |||
#if V8_MAJOR_VERSION >= 7 | |||
#if V8_MAJOR_VERSION >= 7 || defined(NAN_HAS_V8_7_DEPRECATIONS) |
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.
You could use #if NODE_MODULE_VERSION >= NODE_10_0_MODULE_VERSION
to use the same API independent of the minor node version.
* while waiting for nodejs/nan#811
Hide deprecation warnings - see nodejs/nan#811
Any update on this? It seems like a lot of modules are fixing this themselves by adding |
Hide deprecation warnings - see nodejs/nan#811
v10.12.0 turns on a number of V8 deprecation warnings. This commit fixes them in NAN. Fixes: nodejs/nan#810 PR-URL: nodejs/nan#825 Refs: nodejs/nan#811 Reviewed-By: Benjamin Byholm <[email protected]>
node commit: nodejs/node@46c7d0d
Fixes #810