logdna-winston icon indicating copy to clipboard operation
logdna-winston copied to clipboard

Application stalled when logging

Open AmicoJoules opened this issue 6 years ago • 5 comments

Node version: 8.9.3

Configuration:

"logdna": {
        "index_meta": true,
        "key": "xxxxxxxxxxx",
        "env": "development" 
}

The first batch of logs is correctly sent and we can see them in the UI but after that the process just freezes and the CPU usage just rockets up.

AmicoJoules avatar Aug 29 '18 22:08 AmicoJoules

The log that we sent and that is causing our app to freeze is

"response": {
    "statusCode": 200,
    "body": "\n{\"data\":{\"patName\":\"ALXXX\",\"patLastname\":\"CHXXX\",\"patSurename\":\"XXX\",\"patBdate\":\"19XX-XX-XX\",\"patGender\":\"X\",\"patEmail\":\"alXX@XXXX\",\"patTelephone\":\"+XXYYYYYY\",\"calle\":\"\",\"numeroCalle\":\"\",\"colonia\":\"\",\"delegacion\":\"\",\"cp\":\"\",\"ciudad\":\"\",\"dia\":\"XX\",\"mes\":\"XX\",\"anio\":\"19XX\",\"is_SDI\":\"No\",\"ultiLimpieza\":null},\"error\":\"\"}",
    "headers": {
      "date": "Mon, 03 Sep 2018 04:16:41 GMT",
      "server": "Apache",
      "vary": "Accept-Encoding",
      "content-length": "337",
      "connection": "close",
      "content-type": "text/html; charset=UTF-8"
    },
    "request": {
      "uri": {
        "protocol": "https:",
        "slashes": true,
        "auth": null,
        "host": "api.dentalia.com.mx",
        "port": 443,
        "hostname": "api.dentalia.com.mx",
        "hash": null,
        "search": "?api=xxxxx",
        "query": "api=xxxxx",
        "pathname": "/index.php",
        "path": "/index.php?api=xxxxxx",
        "href": "https://api.dentalia.com.mx/index.php?api=xxxxx"
      },
      "method": "POST",
      "headers": {
        "content-type": "multipart/form-data; boundary=--------------------------XXXXXXXXXXXXXX",
        "content-length": 437
      }
    }
  }

AmicoJoules avatar Sep 26 '18 18:09 AmicoJoules

As you can see this is an API call and my guess is that the problem has something to do with how the body is formatted, that's why we had to do a JSON.stringify() and that fix the problem on our side but we are worried that any other API/call could potentially freeze our application as well. Is there anything on your side that can be done to minimize this risk?

AmicoJoules avatar Sep 26 '18 18:09 AmicoJoules

Would you provide more information about how you send the log? I can't reproduce the issue you have.

Below is my setup, run perfectly for me.

var options = {
    key: apikey,
    hostname: 'some host',
    app: 'some app',
    index_meta: true
};
winston.add(winston.transports.Logdna, options);
winston.log('info', 'hi from logdna-winston node: 8.9.3', {yourLogObject});

LYHuang avatar Sep 26 '18 22:09 LYHuang

Hi, I have the same issue. I'm logging a request object and it's stalling. This is the code I have

logger.error({err, property: "data"});

I can get around it by either JSON.stringify() or not passing the err as part of an object, i.e.

logger.error(err, {property: "data"});

Note that the error is an instance of a request error (module request-promise) and has some functions in it

DylanBowden avatar Jan 02 '19 12:01 DylanBowden

@DylanBowden this is usually caused by attempting to log an object that has recursive properties.

You will need to serialize the object/error first before passing it to logdna

I recommend the package serialize-error from npmjs.

You can wrap your error as such:

const serializeError = require('serialize-error');
logger.error("An error occured", { meta: { error: serializeError(err) } });

SirDeadlystrike avatar Feb 02 '19 10:02 SirDeadlystrike