bugsnag-laravel: PHP Fatal error: Allowed Memory Size
On a few occasions where I imagine the stack trace is large, BugsnagLogger is unable to log the error and fails with PHP Fatal error: Allowed Memory Size. This means the original error is lost for good since it isn’t logger and the PHP error logs don’t end up showing this error either as the request fails fatally.
Some kind of check or config option to circumvent this would be very helpful.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 5
- Comments: 27 (12 by maintainers)
See also #19 etc.
Both of those cases are problematic (and my logs indicate both occur).
The Bugsnag client allocates significant amounts of memory in many places. Everything from the static array in
ErrorTypesallocating 32k, to thejson_encode()inHttpClientusing essentially unbound memory (I’ve seen megabytes there).So, both cases happen:
Both result in nothing in Bugsnag. Obviously the first case is purely caused by BugSnag, but the second is pretty poor form too.
In fact, unless the Bugsnag client checks
memory_get_usage(), and optionally issues anini_set()(to account for the extra memory that’s about to be allocated), I don’t see how comments like https://github.com/bugsnag/bugsnag-laravel/issues/19#issuecomment-49816769 (“looks like bugsnag-php should be able to catch memory errors”) can be correct…Maybe PHP used to disable the memory limit after the first time it hit it? It certainly doesn’t any longer.
The most common cases I see are accidental infinite recursion in Eloquent, or the service container. I mean, they are all valid cases, so. We need to keep them all in mind. 😃