node-newrelic: Crash in elasticsearch instrumentation with null body.

Description

https://github.com/newrelic/node-newrelic/blob/main/lib/instrumentation/%40elastic/elasticsearch.js#L58

error.stack: "TypeError: Cannot convert undefined or null to object
	at Function.keys (<anonymous>)
	at Transport.queryParser (/mnt/ramdisk/ecom-api/node_modules/newrelic/lib/instrumentation/@elastic/elasticsearch.js:58:49)
	at DatastoreShim.parseQuery (/mnt/ramdisk/ecom-api/node_modules/newrelic/lib/shim/datastore-shim.js:456:35)
	at Transport.queryRecord (/mnt/ramdisk/ecom-api/node_modules/newrelic/lib/shim/datastore-shim.js:670:25)
	at Transport.wrapper (/mnt/ramdisk/ecom-api/node_modules/newrelic/lib/shim/shim.js:850:33)
	at IndicesApi.indicesExistsApi [as exists] (/mnt/ramdisk/ecom-api/node_modules/@elastic/elasticsearch/api/api/indices.js:361:25)

Expected Behavior

No error.

Steps to Reproduce

Calling indicesExistsApi in @elastic/elasticsearch

About this issue

  • Original URL
  • State: closed
  • Created 9 months ago
  • Reactions: 2
  • Comments: 19 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @mrickard

I’ve tried to upgrade NewRelic from v11.1.0 to v11.5.0, but I’m still getting errors related to ElasticSearch.

We’re using elasticsearch v7.13.0, here is the stack trace:

TypeError: Cannot read properties of null (reading 'then')
at Object.then (/app/node_modules/@elastic/elasticsearch/lib/Transport.js:156:18)
at DatastoreShim.interceptPromise (/app/node_modules/newrelic/lib/shim/shim.js:1713:8)
at DatastoreShim.bindPromise (/app/node_modules/newrelic/lib/shim/shim.js:1729:15)
at Transport._doRecord (/app/node_modules/newrelic/lib/shim/shim.js:937:22)
at Transport.wrapper (/app/node_modules/newrelic/lib/shim/shim.js:887:24)
at Client.bulkApi [as bulk] (/app/node_modules/@elastic/elasticsearch/api/api/bulk.js:67:25)
at tryBulk (/app/node_modules/@elastic/elasticsearch/lib/Helpers.js:691:16)
at bulkOperation (/app/node_modules/@elastic/elasticsearch/lib/Helpers.js:658:7)
at send (/app/node_modules/@elastic/elasticsearch/lib/Helpers.js:629:9)
at iterate (/app/node_modules/@elastic/elasticsearch/lib/Helpers.js:543:9)
at async XXX.YYY (/app/dist/XXX)
at async XXX.ZZZ (/app/dist/XXX)

Would you be able to help with this? I’m happy to create a new issues if you prefer.

@villelahdenvuo This has been released with agent version 11.3.0. Thank you for the report!

@villelahdenvuo Thank you! We’re preparing to ship the release early next week.

@mrickard Luckily it got caught in our E2E tests. 😄