Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(undici): cope with undici@6.11.0 bug that removed req.addHeader #3963

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ See the <<upgrade-to-v4>> 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
Expand Down
7 changes: 6 additions & 1 deletion lib/instrumentation/modules/undici.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
);
}
Expand Down
Loading