fix(core): `.set` the `sentry-trace` header instead of `.append`ing in fetch instrumentation by lforst · Pull Request #13907 · getsentry/sentry-javascript · GitHub
Skip to content

fix(core): .set the sentry-trace header instead of .appending in fetch instrumentation - #13907

Merged
lforst merged 13 commits into
developfrom
lforst-set-headers-instead-of-append
Oct 16, 2024
Merged

fix(core): .set the sentry-trace header instead of .appending in fetch instrumentation#13907
lforst merged 13 commits into
developfrom
lforst-set-headers-instead-of-append

Conversation

@lforst

@lforst lforst commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

Fixes #13870
Fixes #12350

Fixes issues where persistence of the options object passed to fetch() would cause the options object, or rather the attached sentry-trace and baggage headers to indefinitely grow in size.

@github-actions

github-actions Bot commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still curious how we'd attach headers multiple times but I think the change is fine.
I guess as long as we don't find out why this happene(d) testing against would be a bit artificial

@lforst

lforst commented Oct 8, 2024

Copy link
Copy Markdown
Contributor Author

I'm still curious how we'd attach headers multiple times but I think the change is fine.
I guess as long as we don't find out why this happene(d) testing against would be a bit artificial

I think I know a way this can happen. Basically, if you re-use request objects. I'll try to come up with tests.

@codecov

codecov Bot commented Oct 8, 2024

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
536 1 535 129
View the top 1 failed tests by shortest run time
tracing/metrics/web-vitals/test.ts captures time origin and navigation activationStart as span attributes
Stack Traces | 30s run time
test.ts:62:11 captures time origin and navigation activationStart as span attributes

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Lms24 added a commit that referenced this pull request May 5, 2025
…ests (#16184)

Analogously to #16183 for `fetch`, this patch ensures that manually set
`sentry-trace` and `baggage` headers in XHR requests are respected by
our XHR instrumentation and not overwritten.

This patch also fixes a bug where we'd append multiple `sentry-trace` or
`baggage` values in case the header was somehow set more than once
(analogously to
#13907 for `fetch`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants