RuntimeTools / appmetrics-dash

A data visualizer that uses " Node Application Metrics" (appmetrics) to monitor and display Node.js application data as a html web application.
Other
452 stars 55 forks source link

Errors with Node 8: am.emit is not a function (using both appmetrics-dash and appmetrics-prometheus) #124

Open a-roberts opened 6 years ago

a-roberts commented 6 years ago

Application crashes immediately after startup.

/home/aroberts/design-for-cloud/node_modules/appmetrics-dash/node_modules/appmetrics/probes/socketio-probe.js:140
    am.emit('socketio', {
       ^

TypeError: am.emit is not a function
    at SocketioProbe.metricsEnd (/home/aroberts/design-for-cloud/node_modules/appmetrics-dash/node_modules/appmetrics/probes/socketio-probe.js:140:8)
    at /home/aroberts/design-for-cloud/node_modules/appmetrics-dash/node_modules/appmetrics/probes/socketio-probe.js:51:14
    at Namespace.newFunc [as emit] (/home/aroberts/design-for-cloud/node_modules/appmetrics-dash/node_modules/appmetrics/lib/aspect.js:83:14)
    at Server.(anonymous function) [as emit] (/home/aroberts/design-for-cloud/node_modules/appmetrics-dash/node_modules/socket.io/lib/index.js:456:29)
    at Timeout.emitData [as _onTimeout] (/home/aroberts/design-for-cloud/node_modules/appmetrics-dash/lib/appmetrics-dash.js:439:8)
    at ontimeout (timers.js:469:11)

No problems on 6.12.0. Happens regardless of import order, package.json features

  "dependencies": {
    "appmetrics-dash": "^3.3.2",
    "appmetrics-prometheus": "^0.0.2",

The application itself is a Bluemix web starter for Node.js so should be an easy recreate, start a basic Express server with

require('appmetrics-dash').attach();
require('appmetrics-prometheus').attach();

the order of the imports doesn't matter in this case either. IBMers can ping me for the code (it's at github.ibm.com).

sjanuary commented 6 years ago

@a-roberts I don't see this error in my test project running on Node 8 with the same two requires. I'll get the source code from you offline and see what the difference is.

sjanuary commented 6 years ago

This issue turned out to be a clash between 2 installs of appmetrics when using both appmetrics-dash and appmetrics-prometheus. It will be fixed in the next appmetrics release, but a workaround is to make sure that you only have one copy of appmetrics in your node_modules directory so that there is no clash.

dcowden commented 6 years ago

@a-roberts I found this issue because i'm also using both appmetrics-dash and appmetrics-prometheus. I'm trying to find out how to run them both, but using a separate server vs attaching to the main process. Do you know how to do that?