-
Notifications
You must be signed in to change notification settings - Fork 126
upgrade to Node 12 #576
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
upgrade to Node 12 #576
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.
Commented to explain a couple of lines
if (semver.gt(process.version, '10.0.0')) { | ||
|
||
if (semver.gt(process.version, '12.0.0')) { | ||
t.skip(); |
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.
@tobespc suggested skipping this for now
src/appmetrics.cpp
Outdated
s->WriteUtf8(isolate, buf); | ||
#else | ||
s->WriteUtf8(buf); | ||
#endif |
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.
Indentation is kind of off here. Typically the preprocessor lines (e.g. those beginning with #
) would be in column 0 and the code blocks at the same indentation as if the preprocessor lines were not there.
e.g.
static std::string toStdString(Local<String> s) {
char *buf = new char[s->Length() + 1];
#if NODE_VERSION_AT_LEAST(10, 0, 0)
Isolate* isolate = v8::Isolate::GetCurrent();
s->WriteUtf8(isolate, buf);
#else
s->WriteUtf8(buf);
#endif
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.
https://github.com/nodejs/nan/blob/master/doc/string_bytes.md#nandecodewrite perhaps? It shouldn't be necessary to have node version ifdefs, at least not for something as common as string conversions.
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'm not sure how to implement that Nan function tbh, as I don't see how the function name and arguments are related. And Nan seems to implement writeUtf8
using 4 or 5 arguments? Happy to implement this if you show me how
I think option 1 is ok given that Node 6 is no longer in LTS. Agree that a longer term plan to support N-Api would be the right one to avoid issues in the future. We should document that Node 6 is no longer supported and the last known working appmetrics level |
Dropping 6.x support sounds like a good idea to me, but it requires bumping the appmetrics major (because dropping 6 support is a breaking change for people using node 6). That's NBD, but don't forget to do the book keeping: it eans finding all the other runtimes packages (prometheus, etc) that depend on appmetrics, and publishing an updated major of them, that depends on the new appmetrics major. |
src/appmetrics.cpp
Outdated
s->WriteUtf8(isolate, buf); | ||
#else | ||
s->WriteUtf8(buf); | ||
#endif |
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.
https://github.com/nodejs/nan/blob/master/doc/string_bytes.md#nandecodewrite perhaps? It shouldn't be necessary to have node version ifdefs, at least not for something as common as string conversions.
@@ -13,7 +13,7 @@ | |||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
|
|||
#include "node.h" // Picks up BUILDING_NODE_EXTENSION on Windows, see #30. | |||
|
|||
#include "nan.h" |
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.
consider grabbing the most recent https://github.com/bnoordhuis/node-heapdump/blob/master/src/heapdump.cc
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.
+1 Richard and I had discussed this, we just need to check we are able to take a new drop.
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.
opened a new issue #579
@@ -37,7 +37,7 @@ NAN_METHOD(getObjectHistogram) { | |||
|
|||
HeapProfiler *heapProfiler = isolate->GetHeapProfiler(); | |||
|
|||
#if NODE_VERSION_AT_LEAST(4, 0, 0) // > v0.11+ | |||
#if NODE_VERSION_AT_LEAST(4, 0, 0) // > v4.00+ |
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.
unrelated to this PR, but https://github.com/bnoordhuis/node-heapdump/blob/master/src/heapdump.cc#L69-L78 (which is copied into this repo) has a TakeHeapSnapshot(), maybe it can just be called from heapsnapshot/heapsnapshot.cc?
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.
opened a new issue #579
@@ -81,7 +81,13 @@ pushsource* createPushSource(uint32 srcid, const char* name) { | |||
|
|||
static std::string ToStdString(Local<String> s) { | |||
char *buf = new char[s->Length() + 1]; | |||
s->WriteUtf8(buf); | |||
#if NODE_VERSION_AT_LEAST(10, 0, 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.
see previous comment
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.
Indenting again.
The issues raised in the comments will be dealt with as separate PR's |
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
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'd like to be sure we need to drop Node 6 support, that feels wrong especially given we work on Node 6 until this goes in.
- We need to see whether we can update the heapdump code with the latest from the heapdump npm.
@@ -13,7 +13,7 @@ | |||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||
|
|||
#include "node.h" // Picks up BUILDING_NODE_EXTENSION on Windows, see #30. | |||
|
|||
#include "nan.h" |
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.
+1 Richard and I had discussed this, we just need to check we are able to take a new drop.
Travis problemBuild intermittently failing on Windows (various versions of Node) with seemingly the same error in a test in Error output:
Solution
Therefore, we will keep running the Windows tests on Travis but flag them as allowed to fail.
|
I've updated the docs, so this PR also resolves #571 |
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.
Looks good, please use squash and merge to deliver this, there's 20 commits in here and we should add them to master as one logical change.
(These changes break Node 6. See below)
Fix for Node 12:
General information about the V8 API changes between Node 10 and 12
These fixes frequently involve the following:
isolate
object - get viaIsolate* isolate = v8::Isolate::GetCurrent()
context
object - get viaLocal<Context> context = Nan::GetCurrentContext()
MaybeLocal
types returned by many Nan functions toLocal
usingmaybeLocalObj.ToLocalChecked()
Specific error fixes and my specific sources of information
s->WriteUtf8(buf)
tos->WriteUtf8(isolate, buf)
X->ToString()
toNan::To<String>(X).ToLocalChecked()
X->ToObject()
toNan::To<Object>(X).ToLocalChecked()
X->ToInteger()
toNan::To<Integer>(X).ToLocalChecked()
X->GetOwnPropertyNames()
toNan::GetOwnPropertyNames(cache).ToLocalChecked()
X->GetOwnPropertyNames(context).ToLocalChecked()
X->GetFunction()
toX->GetFunction(context).ToLocalChecked()
String::Utf8Value X(Y)
toNan::Utf8Value X(Y)
X->Int32Value()
toX->Int32Value(context).FromJust()
X->IntegerValue()
toX->IntegerValue(context).FromJust()
kApiPointerSize
tokApiSystemPointerSize
isolate->GetCpuProfiler()
to ... (larger fix, because whereas the V8 engine previously had just 1 CpuProfiler, it now has multiple)const Handle<String> X
toconst Local<String> X
node-gyp
from v3 to v4Specific deprecation warning fixes and my specific sources of information
from
X->Get(Y)
toNan::Get(X, Y).ToLocalChecked()
from
X->Set(Y, Z)
toNan::SetMethod(X, Y2, Z2)
X->Set(..)
to their Nan equivalents, see Nan docs https://github.com/nodejs/nan/blob/master/doc/methods.md#nansetprototypemethod and example https://github.com/astro/node-expat/pull/196/files#diff-2b6f822b34553a6cadd4627d4dc9e84fR29)Notes
These changes break Node 6:
Problem:
Error output from `npm i` on Node 6
This can be resolved simply following nodejs/node-gyp#1564 and nodejs/node-gyp#1574. However, that reveals that my upgrade to Node 12 is incompatible with Node 6:
Error output from `CXXFLAGS="-mmacosx-version-min=10.9" LDFLAGS="-mmacosx-version-min=10.9" npm i` on Node 6
Solution 1
Drop Node 6. This PR achieves this.
Solution 2
Support Node 6 alongside 8, 10, and 12. We would need to spend considerable time converting probably ~60% of the fixes in this PR to use NAN and
if
blocks.Ideal long-term solution
Rewrite much of appmetrics using N-API, but that is beyond the scope of this issue.