FriendsOfBehat / SymfonyExtension

:musical_score: Extension integrating Behat with Symfony.
MIT License
472 stars 62 forks source link

Too many connections - Doctrine #104

Closed asoupper closed 4 years ago

asoupper commented 4 years ago

Hello, I have a major problem running a large feature file containing a lot of scenarios. After some scenarios, I get the following exception: An exception occurred in driver: SQLSTATE[08004] [1040] Too many connections (Doctrine\DBAL\Exception\DriverException)

My feature file looks like this:

Feature: Check all possible pages

  Scenario Outline: Checking system routes
    Given I am on "<path>"
    Then the response status code should be 200
    Examples:
      | path              |
      | / |
      | /login |
      | /logout |
      ...

Let's say that I have more than 100 url to check.

It seems that the Doctrine connections are not correctly closed.

I tried adding this but it does not solve the issue:

    /**
     * @AfterScenario
     */
    public function closeConnections(AfterScenarioScope $event)
    {
        $doctrine = $this->container->get('doctrine');
        foreach ($doctrine->getConnections() as $connection)
        {
            $connection->close();
        }
    }
pamil commented 4 years ago

What is your context configuration? How is it implemented?

ayalacp commented 2 years ago

@asoupper we're also having a similar issue, did you find a solution?