Skip to content

thirdPartyErrorFilterIntegration: failed fetch in a third-party script is never treated as third-party with exclusively behaviour #27175

In progress

Description

@nnn3d

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/nextjs

SDK Version

10.78.0 (also reproduces on 11.23.0)

Framework Version

Next 15.5.29

Link to Sentry event

No response

Reproduction Example/SDK Setup

Repro: https://github.com/nnn3d/tmp-sentry-third-party-filter-repro (open /?case=fetch)

// next.config.mjs
export default withSentryConfig(nextConfig, {
  applicationKey: 'repro-app',
  sourcemaps: { disable: true },
  release: { create: false, finalize: false },
  telemetry: false,
});
// instrumentation-client.js
Sentry.init({
  dsn: '...',
  integrations: [
    Sentry.thirdPartyErrorFilterIntegration({
      filterKeys: ['repro-app'],
      behaviour: 'apply-tag-if-exclusively-contains-third-party-frames',
      ignoreSentryInternalFrames: true,
    }),
  ],
});

// Third-party script loaded after init, like a tag manager does
const script = document.createElement('script');
script.src = '/third-party-fetch.js';
document.body.appendChild(script);
// public/third-party-fetch.js (served as-is, not processed by the bundler)
fetch('https://nonexistent.invalid/');

Steps to Reproduce

  1. Clone the repro, npm install && npm run build && npm start.
  2. Open http://localhost:3000/?case=fetch in Chrome.
  3. The page prints the event from beforeSend: third_party_code tag and frames with firstParty (= frame has the application key in module_metadata).

Expected Result

The error comes entirely from a third-party script, so the event is tagged with third_party_code: true.

Actual Result

The event is not tagged with third_party_code: true

Additional Context

  • In production this affects every failed fetch made by ad/marketing scripts. For us that is tens of thousands of events per week that are classified as first-party.
  • The fetch instrumentation is always in the path for these errors. It is the one that appends the host to the message (Failed to fetch (host)), so the filter could reliably skip the topmost frame for such errors. For example, the instrumentation could mark the error object (as it already does with __sentry_fetch_url_host__ when enhanceFetchErrorMessages is not 'always'), or the filter could treat the instrumentation frame as internal in the same way as sentryWrapped.

Priority

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions