Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spotlight overlay crashing due to browser being out of memory #521

Closed
xt0rted opened this issue Sep 11, 2024 · 4 comments · Fixed by #522
Closed

Spotlight overlay crashing due to browser being out of memory #521

xt0rted opened this issue Sep 11, 2024 · 4 comments · Fixed by #522
Assignees
Labels
Type: Bug-confirmed Something isn't working

Comments

@xt0rted
Copy link

xt0rted commented Sep 11, 2024

I recently added Spotlight via the CDN with Sidecar running in Docker to an old AngularJS application using Sentry 7.99. At the time it worked great, then the branch sat for a couple weeks. Today I picked it back up and now devtools keeps pausing saying it's doing that to prevent an out of memory crash. With devtools not open the tab just randomly crashes.

When devtools pauses it's always on one of these two lines:

[integrationName]: [...(prev[integrationName] || []), newIntegrationData],

const processedEvents = integrationData[integration.name]?.map(container => container.event) || [];

Checking prev or integrationData showed it had over 150k items at one point. This happens without even interacting with the site. A fresh page load that sits for a minute can have 50k+ items in the list, and 3x that a few minutes later. This seems to be worse when traceSampleRate is set to 1 instead of something lower, or just completely off.

Nothing's showing in Sidecar when I go directly to http://localhost:8969/, but it is showing in the overlay on my site.

I was loading the latest version of the overlay from the CDN (as the docs show), but if I revert back to v2.3.0 the issue goes away. This seems like something related to #509 but I'm not sure what exactly changed in later versions to stop Spotlight from sending to the Docker instance of Sidecar.

I'm not using the iife bundle because I wanted to change the config. This is how I'm loading it:

<script type="module">
    import { console, init, sentry } from 'https://unpkg.com/@spotlightjs/overlay@2.3.0/dist/sentry-spotlight.js';

    init({
        anchor: 'bottomLeft',
        integrations: [sentry(), console()],
    });
</script>
@BYK BYK self-assigned this Sep 12, 2024
@BYK BYK added the Type: Bug-confirmed Something isn't working label Sep 12, 2024
@BYK
Copy link
Member

BYK commented Sep 12, 2024

Hi @xt0rted and thanks for the report! So there are a few things going on:

  1. The newer version uses a direct communication channel for the frontend bit so you don't need the sidecar. This was to make the IIFE version work out of the box with a "just drop this script" experience
  2. Since the newer version does not rely on the sidecar for buffering, it buffers events in local indexed DB storage. So deleting local storage should "fix" your immediate lock up issue.

That said there are still two major issues we should fix on our end:

  1. The operational complexity of the integrationData line is far from optimal (the first line you pointed out) -- Turns out this is the best and most efficient way for now.
  2. Apparently we should add a max number of events that we store on top of an expiry date
  3. For some reason the console() integration causes these excessive events so that needs to be investigated. I'll file a separate issue for that.

Finally, we just introduced __spotlight.initOptions = {} where you can pass init options to Spotlight so you can use the drop-in IIFE version. It doesn't support integrations yet (as they won't be available as functions ahead of time) but if there's demand we'll work on that bit too.

BYK added a commit that referenced this issue Sep 12, 2024
This pach overhauls the initial rerender with better use of hooks, namely `useCallback` but also using intial state creation function to fix the infinite render loop reported in #521.

Fixes #521.
@BYK BYK closed this as completed in df9cd95 Sep 12, 2024
@BYK BYK closed this as completed in #522 Sep 12, 2024
@BYK
Copy link
Member

BYK commented Sep 12, 2024

@xt0rted thanks again for the report and apologies for the issue. Don't know how I didn't catch this earlier! A new patched version is being released right now and hopefully by the time you read this message, it should be available.

BYK added a commit that referenced this issue Sep 13, 2024
Our console integration was designed to work on the same page with the
Spotlight UI. It was using a naive filtering method to avoid infinite
loops from Spotlight debug mode logger itself. Moreover, it was not
taking the `sidecarURL` option, was defaulting to `localhost:8969` as
the sidecar URL. This patch overhauls the two, leveraging the fact that
they are on the same page. This means switching to the local event-based
message passing between the UI and the console integration, removing the
need for `fetch` calls and passing around the sidecarURL option. It also
overhauls the Spotlight logger to always try to use an unmodified
console implementation, removing the need for hacky filtering on the
console integration side.

ref #521.
@xt0rted
Copy link
Author

xt0rted commented Sep 27, 2024

@BYK I just gave v2.5.1 a try and the issue seems to be resolved.

With the recent changes should I be seeing events logged to my instance of sidecar that's running inside docker, or are they only stored in the browser now? I'm running a .net backend with angularjs frontend, and I'm seeing the .net stuff logged to docker, but the angular stuff doesn't seem to show up over there. I see both the .net & angular stuff in the UI inside my site though.

@BYK
Copy link
Member

BYK commented Sep 29, 2024

@xt0rted thanks a lot for reporting back! Yes, that's exactly what I'd expect to see if Spotlight UI is running on the same page with your front end. We made this change to let people try Spotlight with just a script tag on their front end. We bypass the sidecar when we know we can talk to the Spotlight UI directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug-confirmed Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants