[raven-js] Callback to handle Request Entity Too Large

The stack for our website includes React and Redux. There is a nice helpful redux middleware called redux-raven-middleware which we are using. It attaches the complete or a subset/processed state tree with the error on sentry.

Now depending upon what has the user been doing on the website and what all is there in the stack, the request can become really large. For example, the state can remain small but the breadcrumbs can be huge or it can be the other way round as well. While we trim the state to absolutely what is necessary, we cannot control breadcrumbs’ size and we don’t want to trim the breadcrumbs as well as that’s helpful information.

Is there a way that I can handle if sentry gets request entity too large? The first thing that I want to do with this is just measure how many errors are we missing because of the request being too large. If that happens too much, we’d like to do something else to log them.

we cannot control breadcrumbs’ size

Yes, you can – there’s even two methods:

  1. Reduce the number of breadcrumbs collected (see maxBreadcrumbs).
  2. There is additionally a breadcrumbCallback config option that lets you filter/reduce breadcrumb data it is recorded.

raven-redux-middleware also attaches the entire Redux store application state, which could also be the cause. If that’s configurable, consider disabling it.

Note that at the time of this posting, sentry.io accepts payloads up to 100 KB. Anecdotally from my own testing, a typical error event with ~20 frames, ~50 breadcrumbs is only in the 20-30 KB range.