sentry-laravel icon indicating copy to clipboard operation
sentry-laravel copied to clipboard

Ensure out-of-memory errors are reported

Open spawnia opened this issue 1 year ago • 1 comments

Problem Statement

When PHP hits the configured memory_limit, a fatal error is thrown. The Laravel framework is configured to handle such fatal errors through register_shutdown_function() and frees some memory to allow further processing of the error (about 32k as of https://github.com/laravel/framework/pull/42646/files). When that reserved memory is exceeded again, the process abruptly stops.

I found that this SDK sometimes fails to report out-of-memory errors, most likely due to excessive memory usage during reporting. In our application, errors such as Allowed memory size of x exceeded make it to Sentry only some amount of times. Other times, the process just crashes abruptly with no indication as to what went wrong.

Solution Brainstorm

I suspect that the breadcrumbs and other information that is already stored in the SDK context leading up to the out-of-memory error influence how much memory is used to report the error. Perhaps the SDK can detect out-of-memory errors and somehow limit the amount of memory it consumes to be well under the

spawnia avatar Jun 13 '24 10:06 spawnia