TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string

  • Updated

Issue

The following error(s) are being seen in the Contrast Node agent logs when trying to instrument your application:

{
"level": 50,
"time": 1707264286900,
"pid": 57437,
"hostname": "LTAN-C02DL1KHMD6R",
"name": "contrast",
"err": {
"type": "TypeError",
"message": "The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined",
"stack": "TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined\n at new NodeError (node:internal/errors:399:5)\n at Function.from (nod\e:buffer:339:9)\n ...,
"code": "ERR_INVALID_ARG_TYPE"
},
"msg": "A fatal agent installation error has occurred. The application will be run without instrumentation."
}

Cause

This could happen if your Node app spawns off many child processes or the application has a nested package.json, and the Node agent cannot find an application.name. This property defaults to the name key in the package.json

Resolution

This error can be resolved by setting a value for application.name in the agent configuration yaml or as an environment variable.

Yaml example:

application:
name: MyAppName

Env var example:

CONTRAST__APPLICATION__NAME=MyAppName

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request