Skip to content

Conversation

@andreiborza
Copy link
Member

The thirdPartyErrorFilterIntegration was not able to identify first-party worker code as because module metadata stayed in the worker's separate global scope and wasn't accessible to the main thread.

We now forward the metadata the same way we forward debug ids to the main thread which allows first-party worker code to be identified as such.

Closes: #18705

The `thirdPartyErrorFilterIntegration` was not able to identify first-party
worker code as because module metadata stayed in the worker's separate global
scope and wasn't accessible to the main thread.

We now forward the metadata the same way we forward debug ids to the main thread
which allows first-party worker code to be identified as such.

Closes: #18705
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 11,558 - 8,796 +31%
GET With Sentry 2,044 18% 1,689 +21%
GET With Sentry (error only) 7,740 67% 5,873 +32%
POST Baseline 1,218 - 1,171 +4%
POST With Sentry 608 50% 580 +5%
POST With Sentry (error only) 1,055 87% 1,051 +0%
MYSQL Baseline 4,079 - 3,182 +28%
MYSQL With Sentry 615 15% 427 +44%
MYSQL With Sentry (error only) 3,396 83% 2,606 +30%

View base workflow run

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

Comment on lines 279 to 300
// Must have at least one of: debug IDs, module metadata, or worker error
const hasDebugIds = '_sentryDebugIds' in eventData;
const hasModuleMetadata = '_sentryModuleMetadata' in eventData;
const hasWorkerError = '_sentryWorkerError' in eventData;

if (!hasDebugIds && !hasWorkerError) {
if (!hasDebugIds && !hasModuleMetadata && !hasWorkerError) {
return false;
}

// Validate debug IDs if present
if (hasDebugIds && !(isPlainObject(eventData._sentryDebugIds) || eventData._sentryDebugIds === undefined)) {
return false;
}

// Validate module metadata if present
if (
hasModuleMetadata &&
!(isPlainObject(eventData._sentryModuleMetadata) || eventData._sentryModuleMetadata === undefined)
) {
return false;
}

Copy link
Member

Choose a reason for hiding this comment

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

l: I'm wondering if we should turn around this validation logic to default to false and only emit true in case we find fitting fields on the event data? This would make it easier to add new fields because we don't have to always extend the first if (!hasDebugIds && !hasModuleMetadata && !hasWorkerError) check. wdyt?

(logaf-l so feel free to skip)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that ends up with even more complicated code because we still need to ensure that present fields are validated, we can't exit early basically. The code is more readable this way, unless I'm missing something 😅.

* @param metadataMap - A map of filename to metadata object
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function mergeMetadataMap(metadataMap: Record<string, any>): void {
Copy link
Member

Choose a reason for hiding this comment

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

q: IIUC we need this because we need to update the filenameMetadataMap once we receive the message from the worker, correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, but based on your follow up question I reworked this, no need for it anymore!

*/
export function registerWebWorker({ self }: RegisterWebWorkerOptions): void {
// Send debug IDs to parent thread
const moduleMetadata = self._sentryModuleMetadata ? getFilenameToMetadataMap(defaultStackParser) : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

naive q: why do we need to parse the self._sentryModuleMetadata here? can't we do this in the main thread in mergeMetadata, potentially by re-calling ensureMetadataStacksAreParsed?

I'm probably missing something, so just asking 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

No, you're right. We don't need to parse the module metadata on the worker, can just pass it along and handle everything on the main-thread. That should reduce code and some api I exposed.

Thanks!

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

🙏

interface WebWorkerMessage {
_sentryMessage: boolean;
_sentryDebugIds?: Record<string, string>;
_sentryModuleMetadata?: Record<string, any>; // eslint-disable-line @typescript-eslint/no-explicit-any
Copy link
Member

Choose a reason for hiding this comment

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

l: Why not unknown?

Copy link
Member Author

Choose a reason for hiding this comment

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

To be aligned with the way we define it in the main-thread, maybe we can change that at a later point?

@andreiborza andreiborza force-pushed the ab/third-party-errors-workers branch from 65aefd3 to 72a0090 Compare January 9, 2026 14:35
@andreiborza andreiborza force-pushed the ab/third-party-errors-workers branch from 72a0090 to 81ddea1 Compare January 9, 2026 14:52
@andreiborza andreiborza requested a review from Lms24 January 9, 2026 15:11
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Thanks!

@andreiborza andreiborza merged commit 7868fe5 into develop Jan 9, 2026
208 checks passed
@andreiborza andreiborza deleted the ab/third-party-errors-workers branch January 9, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

thirdPartyErrorFilterIntegration misidentifies first-party web workers and wasm as third-party

4 participants