Skip to content

Commit 4cdedb2

Browse files
trentmPeterEinberger
authored andcommitted
fix(undici): copy with [email protected] bug that removed req.addHeader (elastic#3963)
1 parent 23546c9 commit 4cdedb2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.asciidoc

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ See the <<upgrade-to-v4>> guide.
4747
* Fix path resolution for requests that contain invalid characters in its
4848
host header. ({pull}3923[#3923])
4949
* Fix span names for `getMore` command of mongodb. ({pull}3919[#3919])
50+
* Fix undici instrumentation to cope with a bug in [email protected] where
51+
`request.addHeader()` was accidentally removed. (It was re-added in
52+
5053
5154
[float]
5255
===== Chores

lib/instrumentation/modules/undici.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ function instrumentUndici(agent) {
133133
propSpan.propagateTraceContextHeaders(
134134
request,
135135
function (req, name, value) {
136-
req.addHeader(name, value);
136+
if (typeof request.addHeader === 'function') {
137+
req.addHeader(name, value);
138+
} else if (Array.isArray(request.headers)) {
139+
// [email protected] accidentally, briefly removed `request.addHeader()`.
140+
req.headers.push(name, value);
141+
}
137142
},
138143
);
139144
}

0 commit comments

Comments
 (0)