Skip to content

memory leak in browserTracingIntegration.ts #21630

@SimonSiefke

Description

@SimonSiefke

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

dont know

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

  1. Go to https://syntax.fm/
  2. Click on shows
  3. Click on videos
  4. Repeat steps 2-3 several times
  5. Notice the number of sentry related functions seems to grow each time

Expected Result

The number of sentry related functions stays constant

Actual Result

The number of sentry related functions seems to grow each time

Image

Additional Context

Possible solution: add {once: true} to event listener options to automatically clean up the listener:

// browserTracingIntegration.ts

// Enable auto finish of the pageload span if users are not explicitly ending it
if (isPageloadSpan && !enableReportPageLoaded && optionalWindowDocument) {
  optionalWindowDocument.addEventListener('readystatechange', () => {
    emitFinish();
  }, {once: true });  // clean up listener automatically

  emitFinish();
}

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.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions