-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Xdebug: Maximum function nesting level reached #117
Comments
Set Remember to restart your server after saving php.ini file. |
Hi @Barcelonczyk and thank you for commenting. This is how I solved the problem for now ... I increased the xdebug's max_nesting_level. |
@LaurentEsc stacktrace seems like endless recurrency. Have you change anything or only increased |
No I didn't change anything. Increasing the max_nesting_level to 400 solved the problem temporary. the problem actually just occurred again as my test suite grew to 77 tests, 203 assertions, and I had to increase the max_nesting_level to 500. The stack trace indeed looks like an endless recurrency, but I don't think it is the case: my tests actually run green without error when I increase the limit. they would of course fail if there was some kind of endless loop somewhere... I honestly don't know what is going on and why the tests are reaching this xdebug limit after so many calls of Pipeline and Mappable/Hooks. It also really seems to depend on the size of the test suite and to get worse as it grows. |
I will try to take a better look this week and see if I'm using the package incorrectly. Maybe I am doing something wrong? Please let me know if you think of any misuse that could lead to my problem. |
Also seem to be hitting this issue. Increasing the max nesting level does not seem like a good solution. Why does the infinite loop occur at all, and why only once the test-suite reaches a certain size? I can get the test in question to pass alone or in a smaller set; the function nesting error only occurs when it is run after other tests. |
If some people wonders how to fix it without having to change the limit of nested level, where what to do on the tearDown:
Explanation: when you are using sofa/eloquence on your models it adds something calls $hooks. For example if you are using Mappable:
The problem is, it is static and it stacks instead of replacing the previous values, and later they are using it to loop through it and call all the hooks of a method. So every time you do a new Model(), new query etc, it cumulates hooks and nothing is resetting it. So the more tests you are adding, without resetting the hooks for each class which are using One last thing as you are on a test, you want to avoid to call the flushHook on class which are mock, that's why I have added this condition:
If you are not using Mockery, you can remove it. If you are using another lib for the stub/mock, replace |
It seems you also need to run |
Was this ever fixed in core? The solution presented above may resolve in certain test scenarios but it looks like it might be preventable in the first place. I've got a test suite of ~1000 tests, 5000 assertions and it's not possible for me to even run all tests anymore. Using a bash script to run one-by-one I can execute each test, but as a suite, I can see that the hooks are being carried over from one test to the next. |
Prevent the trait from booting each time a class is instantiated. See jarektkaczyk/eloquence#117 for description of the issue this resolves.
I was having a similar issue with my testing. After spending more time than I'd like to admit chasing down the issue, I found this thread and the explanation from @lemasson-h was very helpful. Continually increasing Please see the PR I submitted above. With this fix, my own environment continues to function well. Also, my tests complete in less than 30% of the time they used to take! I'm open to feedback, but I suspect this may fix the issue. |
Hello,
I am having trouble running my PHPunit tests with xdebug on, and I think the problem might come from this package.
Until a recent change in my code, I had no problems running tests while my models were already using Eloquence. But today, I added 4 classes that inherit my Product model to provide different logics according to the type of product (Ex: AboProduct, StandardProduct...), which I think improves my code.
Here is how my Product model looks like:
Here is how a concrete product class looks like:
Here is how my controller looks like
Now, as written above, I am having problems during my tests. Otherwise, everything works as intended. My tests are actually green and run without problem when I run them individually or filtered. It seems that the problem only happens when I run a large part of my test suite.
Here is the error that I get:
And here an extract of the stack trace (the last traces before it fails):
I don't really know what is going on, but seeing this stack trace I think here could be the right place to ask. I also suspect this might be related to #96 of @maltsev;
Hopefully someone can help :) Thanks
Please note that I'm using the v5.2.5 of Eloquence.
The text was updated successfully, but these errors were encountered: