elastic / apm-agent-nodejs

https://www.elastic.co/guide/en/apm/agent/nodejs/current/index.html
BSD 2-Clause "Simplified" License
582 stars 224 forks source link

`TypeError: Cannot convert undefined or null to object` from elastic-apm-http-client #1512

Closed anotheri closed 2 years ago

anotheri commented 4 years ago

Describe the bug

APM server doesn't show tracked transactions data, although all the logs in node application (even with logger level trace) show that everything's ok. After some investigation and enabling logUncaughtExceptions: true I've noticed the next error: TypeError: Cannot convert undefined or null to object from elastic-apm-http-client module (see the full error trace log in "additional context" section below). As far as i've got it happens when it tries to send cache/redis transaction tracked from connect-redis dependency used as session storage. To fix (skip) the issue i've added filter like this if (payload.type === 'cache') return false;.

Environment (please complete the following information)

How are you starting the agent? (please tick one of the boxes)

Additional context

paul-pagnan commented 4 years ago

Bump - I am also receiving this error. I have disabled redis using the disableInstrumentations: ['ioredis'] option in the apm.start which seems to have removed the error

I am on ioredis version 4.14.0 APM Agent version: 3.1.0 APM Server Version: Node Version: 12.12 OS: Mac Catalina 10.15.2 - Also occurs in Docker Ubuntu 18.10

trentm commented 2 years ago

I realize this is years after the fact, but I believe this was:

  1. caused by https://github.com/elastic/apm-nodejs-http-client/pull/92/files#diff-0760ae25bbc618d8dcaf155372899ace802823e490f6b28f1716bb8b9abf6318R305-R309 (that change in the elastic-apm-http-client dep used by this agent would allow an attempt to Object.keys(null):
> Object.keys(null)
Uncaught TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)

This was released as elastic-apm-http-client@9.1.0

  1. Then was fixed shortly after in https://github.com/elastic/apm-nodejs-http-client/pull/93 and released as elastic-apm-http-client@9.1.1.

Apologies for the silence on this issue for so long and please re-open if you are hitting this same error with an agent (elastic-apm-node) that is at all recent.