Skip to content

Wrong request headers when instrument the fetch with 2 parameters and they both have headers #10172

Closed

Description

@Kaciras

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/vue

SDK Version

7.93.0

Framework Version

Vue 3.4.10

Link to Sentry event

No response

SDK Setup

Sentry.init({
	// dsn: "",
	tracesSampleRate: 1.0,
	integrations: [
		new Sentry.BrowserTracing(),
	],
});

Steps to Reproduce

const request = new Request("/test", {
	headers: { foo: "11" },
});
fetch(request, {
	headers: { bar: "22" },
});

Expected Result

The request should have the header bar: 22.

Actual Result

request

I believe it was a mistake in selecting the request headers to be merged.

const headers =
typeof Request !== 'undefined' && isInstanceOf(request, Request) ? (request as Request).headers : options.headers;

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 2on Jan 13, 2024
  2. Lms24 commented on Jan 15, 2024

    @Lms24
    Member

    Hey @Kaciras, thanks for writing in and for the reproduction steps! I'll take a look at this today, will keep you up to date on my findings.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 2on Jan 15, 2024
  4. self-assigned this
    on Jan 15, 2024
  5. Lms24 commented on Jan 15, 2024

    @Lms24
    Member

    Hi @Kaciras again, thank you for the reproduction steps and for even finding the incorrect line of code. I tested this, both live in Chromium as well as in our integration test setup and could confirm that browsers indeed seem to prefer the init options over the fetch input option (i.e. the Request passed to the first argument of the fetch call). So you were right, our instrumentation forwarded the wrong headers. I pushed a fix in #10176 which will be included in the next release. We'll probably publish the next release around mid-week.

  6. ghost added on Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions