Skip to content
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
9 changes: 7 additions & 2 deletions packages/node/src/integrations/undici/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,13 @@ function setHeadersOnRequest(
sentryTrace: string,
sentryBaggageHeader: string | undefined,
): void {
const headerLines = request.headers.split('\r\n');
const hasSentryHeaders = headerLines.some(headerLine => headerLine.startsWith('sentry-trace:'));
let hasSentryHeaders: boolean;
if (Array.isArray(request.headers)) {
hasSentryHeaders = request.headers.some(headerLine => headerLine === 'sentry-trace');
} else {
const headerLines = request.headers.split('\r\n');
hasSentryHeaders = headerLines.some(headerLine => headerLine.startsWith('sentry-trace:'));
}

if (hasSentryHeaders) {
return;
Expand Down
4 changes: 3 additions & 1 deletion packages/node/src/integrations/undici/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ export interface UndiciRequest {
// Originally was Dispatcher.HttpMethod, but did not want to vendor that in.
method?: string;
path: string;
headers: string;
// string for undici@<=6.6.2 and string[] for undici@>=6.7.0.
// see for more information: https://github.com/getsentry/sentry-javascript/issues/10936
headers: string | string[];
addHeader(key: string, value: string): RequestWithSentry;
}

Expand Down