When both Ray and Flare are installed on a Laravel project and a report function is called inside of a view, the Laravel app ends up in an infinite loop when Ray tries to create a Flare report:
While creating a Flare report, an array representation of the stack trace is produced by the spatie/backtrace package, where each method call argument is ran through these "reducer" classes. This issue is specifically caused by the StringableArgumentReducer which invokes the magic __toString() method on any argument in the stack trace that implements it. In Laravel, this method is implemented by the View class and a view is normally passed as an argument to the Response::setContent() function. Casting the view into a string causes it to re-render, calling the report function again, repeating this whole process.
While writing this issue I realized this might have more implications in the Flare client package. I will create a separate issue with an example repo there, linking back to this.
When both Ray and Flare are installed on a Laravel project and a report function is called inside of a view, the Laravel app ends up in an infinite loop when Ray tries to create a Flare report:
https://github.com/spatie/laravel-ray/blob/1d10366c91e38fd0e1284988f66551dea0e03e54/src/Watchers/ExceptionWatcher.php#L63-L68
While creating a Flare report, an array representation of the stack trace is produced by the
spatie/backtrace
package, where each method call argument is ran through these "reducer" classes. This issue is specifically caused by theStringableArgumentReducer
which invokes the magic__toString()
method on any argument in the stack trace that implements it. In Laravel, this method is implemented by theView
class and a view is normally passed as an argument to theResponse::setContent()
function. Casting the view into a string causes it to re-render, calling the report function again, repeating this whole process.While writing this issue I realized this might have more implications in the Flare client package. I will create a separate issue with an example repo there, linking back to this.