Skip to content

thirdPartyErrorFilterIntegration not working with webpack #12827

@jankalfus

Description

@jankalfus

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

8.15.0

Framework Version

18.3.1

Link to Sentry event

No response

SDK Setup/Reproduction Example

Sentry.init({
  debug: true,
  dsn: 'our-dsn',
  environment: process.env.NODE_ENV,
  integrations: [
    browserTracingIntegration(),
    replayIntegration(),
    feedbackIntegration,
    thirdPartyErrorFilterIntegration({
      filterKeys: ['our-app'],
      behaviour: 'drop-error-if-contains-third-party-frames',
    }),
  ],
})

Steps to Reproduce

  1. install @sentry/react 8.15.0, @sentry/webpack-plugin 2.20.1
  2. Set up thirdPartyErrorFilterIntegration according to the docs: https://docs.sentry.io/platforms/javascript/configuration/filtering/#using-thirdpartyerrorfilterintegration, so:
Sentry.init({
  debug: true,
  dsn: 'our-dsn',
  environment: process.env.NODE_ENV,
  integrations: [
    browserTracingIntegration(),
    replayIntegration(),
    feedbackIntegration,
    thirdPartyErrorFilterIntegration({
      filterKeys: ['our-app'],
      behaviour: 'drop-error-if-contains-third-party-frames',
    }),
  ],
})

and in webpack.config.js:

module.exports = {
  //...
  plugins: [
    //...
    sentryWebpackPlugin({
      applicationKey: 'our-app',
    }),
  ]
}
  1. run webpack dev server (cross-env NODE_ENV=development node ./node_modules/webpack/bin/webpack.js serve)
  2. Throw an error from the application upon clicking a button (simple throw Error("my test") in the button’s onClick event handler)

Expected Result

Since the error originates in the application code, it should get logged to Sentry.

Actual Result

The error doesn’t get logged to Sentry.

I can see the following logs in the browser console:

logger.js:83 Sentry Logger [log]: Event processor "ThirdPartyErrorsFilter" dropped event
logger.js:83 Sentry Logger [log]: Adding outcome: "event_processor:error"
logger.js:83 Sentry Logger [log]: An event processor returned `null`, will not send event.

When browsing webpack’s memory bundle, I can see the following at the top of the bundled files, so I guess the "our-app" tag seems to get added there, however Sentry still thinks the error originates from 3rd party code for some reason?

;!function() {
    try {
        var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {}
          , n = (new Error).stack;
        n && (e._sentryDebugIds = e._sentryDebugIds || {},
        e._sentryDebugIds[n] = "13ccde7e-de46-4869-8226-5fcff381b6d8",
        e._sentryDebugIdIdentifier = "sentry-dbid-13ccde7e-de46-4869-8226-5fcff381b6d8")
    } catch (e) {}
}();
{
    var _sentryModuleMetadataGlobal = typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};

    _sentryModuleMetadataGlobal._sentryModuleMetadata = _sentryModuleMetadataGlobal._sentryModuleMetadata || {};

    _sentryModuleMetadataGlobal._sentryModuleMetadata[new Error().stack] = Object.assign({}, _sentryModuleMetadataGlobal._sentryModuleMetadata[new Error().stack], {
        "_sentryBundlerPluginAppKey:our-app": true
    });
}

var _global = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

_global.SENTRY_RELEASE = {
    id: "c3b47313407c1a6fc02ab0547364ecf384c5dfe4"
};
// other code continues

Note: I haven’t tried whether this works with the production bundle, only with the dev server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: reactIssues related to the Sentry React SDK

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions