Given the below composer.json configuration, attempting to use Behat (eg, by running bin/behat -h results in the error:
Fatal error: Maximum function nesting level of '100' reached, aborting! in {path}/vendor/composer/ClassLoader.php on line 347
Composer file:
{
"require": {
"behat/behat": "~3.0"
}
}
Result of composer show -i:
behat/behat v3.0.15 Scenario-oriented BDD framework for PHP 5.3
behat/gherkin v4.3.0 Gherkin DSL parser for PHP 5.3
behat/transliterator v1.0.1 String transliterator
symfony/class-loader v2.6.6 Symfony ClassLoader Component
symfony/config v2.6.6 Symfony Config Component
symfony/console v2.6.6 Symfony Console Component
symfony/dependency-injection v2.6.6 Symfony DependencyInjection Component
symfony/event-dispatcher v2.6.6 Symfony EventDispatcher Component
symfony/filesystem v2.6.6 Symfony Filesystem Component
symfony/translation v2.6.6 Symfony Translation Component
symfony/yaml v2.6.6 Symfony Yaml Component
How can I go about debugging this?
I should add that the error doesn't occur if I specify ~2.4 as the behat/behat version.
Add xdebug.max_nesting_level = 1000 to your php.ini file
got it as well..
100 is quite low as max nesting level, and this can indeed cause issues (it depends of how the object graph looks in the container, which is why it may stay below 100 on some versions btw)
@stof you're right, increasing the value "solves" the issue. Would be nice to have this somewhere in the doc.
Thanks. Increasing Xdebug's max_nesting_level does indeed fix this issue.
100 is the default value. If Behat is going to call functions nested more than 100 levels deep then it sounds like a note should be added to the readme.
Aside: 100 levels of nested functions sounds pretty high to me, but I'm far from familiar with Behat's internals.
@johnbillion actually, the default is 256 is the latest versions of XDebug (even though the doc has not been updated, which looks like a mistake).
And this is not only about Behat internals but also about the Symfony ones (moving from 94 to 104 calls IIRC is related to a refactoring in Symfony to fix a bug). And when dealing with nested structures, 100 is actually not that high (I already reached it regularly in other cases dealing with hierarchical structures).
I got similar issue
But this error occur when i put my project out side wamp ...
and in command prompt php app/console server:run
This commang gives me message to run project on http://127.0.0.1:8000 and this time below error comes.
CRITICAL - Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Error: Maximum function nesting level of '100' reached, aborting!" at D:\projects\symfony\vendor\composer\ClassLoader.php line 347
Context: {"exception":"Object(Symfony\Component\Debug\Exception\FatalErrorException)"}
i have set xdebug.max_nesting_level = 1000 in php.ini but it still show max nesting level 100 reached...Pls. guide...
Well, if you still get it with a level set to 1000, you probably have an infinite loop somewhere.
But anyway, if it happens with app/console server:run, it has strictly nothing to do with Behat.
Don't know if related, but I don't want to fill a new issue if it not worth it.
In a *.feature file if I comment more than 122 lines, it causes a nesting level fatal error.
Fatal error: Maximum function nesting level of '256' reached, aborting! in /vendor/behat/gherkin/src/Behat/Gherkin/Lexer.php on line 179
Tell me if I should open a new ticket.
Thanks.
if it can help:
I had this problem. I increased max_nesting_level too. All of these couldn't fix this problem.
I had a long feature file which many of first scenarios were commented. I remove all commented scenarios and this problem was fixed.
@ebrahimdunro do you have the same issue in case of a long file with uncommented scenarios ?
@stof no. after removing the comments everything runs without problem.
Most helpful comment
Add xdebug.max_nesting_level = 1000 to your php.ini file