-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Symfony error page #51
Conversation
After some further testing, this does not seem to fix all issues. In general the Symfony error seems to be thrown during the json_encode of the stack trace :) |
It looks like a cascade effect happening with In my case I had buggy |
The biggest issue currently and why my solution doesn't fully work, is that casted arrays aren't traversed. Unfortunately traversing those results in exceeding the frames, and looks like I'm hitting an endless loop somewhere in Laravel's framework (may be some cyclic references). A better option could be to do a gradual |
/**
* @param array<string, mixed> $data
* @return void
*/
private function recursiveConvertToArray(array &$data, $depth = 0) : void
{
if ($depth == 8)
{
if (is_object($data))
$data = null;
return;
}
foreach ($data as $key => &$value)
{
if(is_object($value))
{
if (is_callable($value))
continue;
try
{
$value = (array)$value;
$this->recursiveConvertToArray($value, $depth + 1);
}
catch (\Exception $e)
{
}
continue;
}
if (is_array($value))
$this->recursiveConvertToArray($value, $depth + 1);
}
} Something like this semi-solves the issue, it allows me to actually retrieve the json encoded string, but you also lose information once a certain depth is hit. Performance-wise this isn't great either. |
This is probably the best solution I can come up with right now, without putting too much time into this 😄 /**
* @param array<string, mixed> $data
* @return void
*/
private function recursiveConvertToArray(array &$data,) : void
{
foreach ($data as $key => &$value)
{
if(is_object($value))
{
try
{
$temp = json_encode($value);
$value = json_decode($temp, true);
$this->recursiveConvertToArray($value);
}
catch (\Exception $e)
{
$value = null;
}
continue;
}
if (is_array($value))
$this->recursiveConvertToArray($value);
}
} I wouldn't call it pretty, but encoding and decoding only remove items that would also be removed when you do This also removes calls that result in the inner exception being thrown, and timewise is much better than my proposal in the last comment. |
Hi @jazerix, it seems like the bulk of this issue comes from the stack frame's arguments being included in the stacktrace (and some of those arguments not being serialisable). I think we're currently not using any of those arguments in Ignition, so getting rid of them in the serialised stacktrace might even be an easier solution. What do you think? For reference: hardcoding |
This is the cause I have discovered as well. |
I honestly don't know, you most likely have a much better understanding of how the internal components work and communicate with each other 😄. I guess in the end it comes down to performance and what you want to preserve. If you truly don't need the arguments anyway, then that is the obvious solution and definitely less costly than what I am proposing 😃 |
Hi again! It looks like removing attributes from the stack frames was all it took to fix the issue so I'm gonna close this PR for now. I really liked your approach to recursively add and check serialisable data before adding it to the report tho. If we ever need to add more dynamic data in the report again I'll re-open this 👍 Thanks for your time and great PR! |
This PR fixes the Symfony error page shown within Ignition, as occurring in issue #48.
This solution is most likely not how you want to solve this issue, but in that case, this can at least point you in the right direction.
I hope it helps :)