Skip to content
Open
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
7 changes: 6 additions & 1 deletion packages/core/src/integrations/third-party-errors-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ function getBundleKeysForAllFramesWithFilenames(
}

function isLikelyMinifiedSentryWrappedFrame(frame: StackFrame): boolean {
return !frame.context_line && !frame.pre_context && !!frame.function && frame.function.length <= 2;
if (frame.context_line || frame.pre_context || !frame.function) {
return false;
}
// Event listener frames in V8 include the receiver type (e.g., `Image.r`, `HTMLIFrameElement.r`).
const fnName = frame.function.split('.').pop();
return !!fnName && fnName.length <= 2;
}

const BUNDLER_PLUGIN_APP_KEY_PREFIX = '_sentryBundlerPluginAppKey:';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,53 @@ describe('ThirdPartyErrorFilter', () => {
const result = await integration.processEvent?.(event, {}, MOCK_CLIENT);
expect(result).toBeDefined();
});

it('detects minified sentryWrapped frame with receiver prefix in event listeners (e.g., Image.r, HTMLIFrameElement.r)', async () => {
for (const fnName of ['Image.r', 'HTMLIFrameElement.r', 'Element.ab']) {
const eventWithListenerSentryFrame: Event = {
exception: {
values: [
{
stacktrace: {
frames: [
{
colno: 12345,
filename: 'https://example.com/assets/app-abc123.js',
function: fnName,
lineno: 1,
module_metadata: {
'_sentryBundlerPluginAppKey:some-key': true,
},
},
{
colno: 1,
filename: 'https://third-party.example/widget.js',
function: 'onLoad',
lineno: 1,
},
],
},
type: 'Error',
value: 'Third party listener error',
},
],
},
};

const integration = thirdPartyErrorFilterIntegration({
behaviour: 'drop-error-if-exclusively-contains-third-party-frames',
filterKeys: ['some-key'],
ignoreSentryInternalFrames: true,
});

GLOBAL_OBJ._sentryWrappedDepth = 1;
const event = clone(eventWithListenerSentryFrame);
integration.preprocessEvent?.(event, {}, MOCK_CLIENT);
GLOBAL_OBJ._sentryWrappedDepth = 0;
const result = await integration.processEvent?.(event, {}, MOCK_CLIENT);
expect(result).toBeNull();
}
});
});
});

Expand Down
Loading