Dd-trace-js: TypeError: headers.authorization.startsWith is not a function

Created on 8 Aug 2018  路  5Comments  路  Source: DataDog/dd-trace-js

Hi! After updating to 0.5.3, I'm now encountering the following error. I'm running on node 8.9.4 (in docker). 0.5.1 (and 0.5.2) are both behaving as expected.

No custom instrumentation has been used, with only the standard setup outlined here: https://docs.datadoghq.com/tracing/setup/nodejs/

TypeError: headers.authorization.startsWith is not a function at hasAmazonSignature (/home/app/ims-ui/server/node_modules/dd-trace/src/plugins/http.js:116:61) at requestTrace (/home/app/ims-ui/server/node_modules/dd-trace/src/plugins/http.js:39:12) at /home/app/ims-ui/server/node_modules/node-fetch/lib/index.js:1375:15 at new Promise (<anonymous>) at fetch (/home/app/ims-ui/server/node_modules/node-fetch/lib/index.js:1367:9) ...

bug community integrations

Most helpful comment

Just released it!

All 5 comments

The code handling this header actually assumes a string. While this is definitely a bug as it shouldn't crash, I would be interested in knowing what is the use case for setting this header, or headers in general, to a value other than a string.

node-fetch sets headers to arrays rather than strings. I think this should be handled since node-fetch is the defacto fetch library for Node.

Here's an example taken from a fetch call made with node-fetch:

{
  "Content-Type": ["application/json; charset=utf-8"],
  "Authorization": ["Basic 123123123123"],
  "Accept": ["*/*"],
  "Content-Length": ["546"],
  "User-Agent": ["node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"],
  "Accept-Encoding": ["gzip,deflate"],
  "Connection": ["close"]
}

It's fixed in master and will be in the next release :)

Is that going to be soon? This is a pretty big issue for us.

Just released it!

Was this page helpful?
0 / 5 - 0 ratings