Skip to content
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

Application stalled when logging #5

Open
AmicoJoules opened this issue Aug 29, 2018 · 5 comments
Open

Application stalled when logging #5

AmicoJoules opened this issue Aug 29, 2018 · 5 comments

Comments

@AmicoJoules
Copy link

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
Copy link
Author

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
Copy link
Author

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?

@LYHuang
Copy link
Contributor

LYHuang commented Sep 26, 2018

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});

@DylanBowden
Copy link

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

@SirDeadlystrike
Copy link

SirDeadlystrike commented Feb 2, 2019

@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) } });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants