RuntimeTools / appmetrics

Node Application Metrics provides a foundational infrastructure for collecting resource and performance monitoring data for Node.js-based applications.
https://developer.ibm.com/open/node-application-metrics/
Apache License 2.0
977 stars 126 forks source link

upgrade to Node 12 #576

Closed rwalle61 closed 5 years ago

rwalle61 commented 5 years ago

(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:

Specific error fixes and my specific sources of information

Specific deprecation warning fixes and my specific sources of information

Notes

These changes break Node 6:

Problem:

Error output from `npm i` on Node 6 ``` /Users/richard.waller@ibm.com/.node-gyp/6.17.1/include/node/v8.h:21:10: fatal error: 'utility' file not found #include ^~~~~~~~~ 1 warning and 1 error generated. make: *** [Release/obj.target/appmetrics/geni/appmetrics.o] Error 1 ```

This can be resolved simply following https://github.com/nodejs/node-gyp/issues/1564 and https://github.com/nodejs/node-gyp/issues/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 ``` In file included from ../src/plugins/node/prof/watchdog.h:21: ../src/plugins/node/prof/compat-inl.h:308:38: error: no member named 'New' in 'v8::CpuProfiler' cpu_profiler_ = v8::CpuProfiler::New(isolate); ~~~~~~~~~~~~~~~~~^ Release/obj.target/appmetrics/geni/appmetrics.cpp:467:29: warning: 'Call' is deprecated [-Wdeprecated-declarations] listener->callback->Call(argc, argv); ^ ../node_modules/nan/nan.h:1673:3: note: 'Call' has been explicitly marked deprecated here NAN_DEPRECATED inline v8::Local ^ ../node_modules/nan/nan.h:103:40: note: expanded from macro 'NAN_DEPRECATED' # define NAN_DEPRECATED __attribute__((deprecated)) ^ Release/obj.target/appmetrics/geni/appmetrics.cpp:530:27: error: no matching constructor for initialization of 'String::Utf8Value' String::Utf8Value str(isolate, Nan::To(info[0]).ToLocalChecked()); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/richard.waller@ibm.com/.node-gyp/6.17.1/include/node/v8.h:2428:14: note: candidate constructor not viable: requires single argument 'obj', but 2 arguments were provided explicit Utf8Value(Local obj); ^ /Users/richard.waller@ibm.com/.node-gyp/6.17.1/include/node/v8.h:2438:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided Utf8Value(const Utf8Value&); ^ Release/obj.target/appmetrics/geni/appmetrics.cpp:542:27: error: no matching constructor for initialization of 'String::Utf8Value' String::Utf8Value str(isolate, Nan::To(info[1]).ToLocalChecked()); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/richard.waller@ibm.com/.node-gyp/6.17.1/include/node/v8.h:2428:14: note: candidate constructor not viable: requires single argument 'obj', but 2 arguments were provided explicit Utf8Value(Local obj); ^ /Users/richard.waller@ibm.com/.node-gyp/6.17.1/include/node/v8.h:2438:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided Utf8Value(const Utf8Value&); ^ Release/obj.target/appmetrics/geni/appmetrics.cpp:570:27: error: no matching constructor for initialization of 'String::Utf8Value' String::Utf8Value topicArg(isolate, Nan::To(info[0]).ToLocalChecked()); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/richard.waller@ibm.com/.node-gyp/6.17.1/include/node/v8.h:2428:14: note: candidate constructor not viable: requires single argument 'obj', but 2 arguments were provided explicit Utf8Value(Local obj); ^ /Users/richard.waller@ibm.com/.node-gyp/6.17.1/include/node/v8.h:2438:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided Utf8Value(const Utf8Value&); ^ Release/obj.target/appmetrics/geni/appmetrics.cpp:572:27: error: no matching constructor for initialization of 'String::Utf8Value' String::Utf8Value commandArg(isolate, Nan::To(info[1]).ToLocalChecked()); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/richard.waller@ibm.com/.node-gyp/6.17.1/include/node/v8.h:2428:14: note: candidate constructor not viable: requires single argument 'obj', but 2 arguments were provided explicit Utf8Value(Local obj); ^ /Users/richard.waller@ibm.com/.node-gyp/6.17.1/include/node/v8.h:2438:5: note: candidate constructor not viable: requires 1 argument, but 2 were provided Utf8Value(const Utf8Value&); ^ 1 warning and 5 errors generated. make: *** [Release/obj.target/appmetrics/geni/appmetrics.o] Error 1 ```

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.

AndyRWatson commented 5 years ago

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

sam-github commented 5 years ago

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.

tobespc commented 5 years ago

The issues raised in the comments will be dealt with as separate PR's

rwalle61 commented 5 years ago

Travis problem

Build intermittently failing on Windows (various versions of Node) with seemingly the same error in a test in http-outbound-probe-test.js.

Error output: ``` [Thu May 30 09:47:02 2019] com.ibm.diagnostics.healthcenter.mqtt INFO: Connecting to broker localhost:1883 Error: connect ECONNREFUSED 127.0.0.1:49860 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14) { name: 'TAP', autoend: true, errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 49860, tapCaught: 'uncaughtException', test: 'TAP' } Error: socket hang up at createHangUpError (_http_client.js:342:15) at Socket.socketCloseListener (_http_client.js:377:23) at emitOne (events.js:121:20) at Socket.emit (events.js:211:7) at TCP._handle.close [as _onclose] (net.js:561:12) { name: 'TAP', autoend: true, code: 'ECONNRESET', tapCaught: 'uncaughtException', test: 'TAP' } # time=92.67ms not ok 3 - tests/probes/http-outbound-probe-test.js # time=5743.445ms --- timeout: 120000 file: tests/probes/http-outbound-probe-test.js childId: 2 command: 'C:\ProgramData\nvs\node\8.16.0\x64\node.exe' args: - '-r' - 'C:\Users\travis\build\RuntimeTools\appmetrics\node_modules\esm\esm.js' - tests/probes/http-outbound-probe-test.js stdio: - 0 - pipe - 2 cwd: 'C:\Users\travis\build\RuntimeTools\appmetrics' exitCode: 1 ... ```

Solution

Therefore, we will keep running the Windows tests on Travis but flag them as allowed to fail.

rwalle61 commented 5 years ago

I've updated the docs, so this PR also resolves https://github.com/RuntimeTools/appmetrics/issues/571