diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 3845bbb4105..9bf604db87b 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -47,6 +47,9 @@ See the <> guide. * Fix path resolution for requests that contain invalid characters in its host header. ({pull}3923[#3923]) * Fix span names for `getMore` command of mongodb. ({pull}3919[#3919]) +* Fix undici instrumentation to cope with a bug in undici@6.11.0 where + `request.addHeader()` was accidentally removed. (It was re-added in + undici@6.11.1.) [float] ===== Chores diff --git a/lib/instrumentation/modules/undici.js b/lib/instrumentation/modules/undici.js index 955bce1c5b6..2f84e9a320c 100644 --- a/lib/instrumentation/modules/undici.js +++ b/lib/instrumentation/modules/undici.js @@ -133,7 +133,12 @@ function instrumentUndici(agent) { propSpan.propagateTraceContextHeaders( request, function (req, name, value) { - req.addHeader(name, value); + if (typeof request.addHeader === 'function') { + req.addHeader(name, value); + } else if (Array.isArray(request.headers)) { + // undici@6.11.0 accidentally, briefly removed `request.addHeader()`. + req.headers.push(name, value); + } }, ); }