Limiting Breadcumgs With React Native Agent

Ed C

Posted on
Mar 28 2021

Is there any way to limit the number of breadcrumbs tracked so we only send the most recent X breadcrumbs when notifying about an error? Specifically with the react native agent.

We're having an issue where errors are being dropped because the submitted payload is too large (I found https://raygun.com/forums/thread/25000 indicating the limit is 100 kb).

Investigating this issue we discovered that it was because there were over 300 breadcrumbs included in the request accounting for about half of the payload. Some of this is because our application creates very fine grained breadcrumbs, but even if we changed that we would still hit this issue after the app has been running for a while since as far as I can tell breadcrumbs are only cleared when an explicit call is made to clearBreadcrumbs.

Is there any way to just limit the number of breadcrumbs recorded so that we can just say "maximum 30 breadcrumbs" or similar and prevent the payload getting too large? Just clearing the breadcrumbs is undesirable since we would then have no context if an error happened shortly after the clear.

For now, we're working around it by wrapping the recordBreadcrumb method in a wrapper that clears the breadcrumbs periodically then re-creates them. E.g.

let breadcrumbs = [];

function safeRecordBreadcrumb(breadcrumb) {
    if (breadcrumbs.length >= 30) {
      /* Clear the breadcrumbs and re-log the last 15.
       * this prevents the breadcumbs growing without bounds
       * while ensuring we have at least 15 for context
       */
      breadcrumbs = breadcrumbs.slice(-15);
      raygun.clearBreadcrumbs();
      breadcrumbs.forEach((crumb) => raygun.recordBreadcrumb(crumb));
    }
    breadcrumbs.push(breadcrumb);

    raygun.recordBreadcrumb(breadcrumb);
}

But it would be really nice if there was a built in way to apply this limit.


Mitchell

Raygun

Posted on
Mar 28 2021

Hi Ed,

Thank you for getting in touch with us. This does appear to be a mistake on our end. We do typically restrict the number of breadcrumbs to the latest 32 crumbs. We will look to release a fix for this over the next day. I will update this thread when the fix has been released. Thanks again for pointing this out.

Regards, Mitchell.


Mitchell

Raygun

Posted on
Mar 30 2021

Hi Ed,

Just following up to let you know we have released an update to the raygun4reactnative SDK to limit the number of breadcrumbs per error report. There is now a hard upper limit of 32 breadcrumbs per report, following the same behaviour as our other SDKs. Please try updating to version 1.1.0 of the raygun4reactnative SDK and let us know if you experience any more issues.

Thank you, Mitchell.


Ed C

Posted on
Mar 30 2021

Excellent. Really appreciate the quick response on this, I'll pull in the new version and see if we can remove our workaround.

Thanks again.


Mitchell

Raygun

Posted on
Mar 30 2021

No problem at all. Let us know if you run into any more issues.

Regards, Mitchell.


Reply