Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Description
Symfony version(s) affected: 3.4 up till current master
Description
When making a request, theTraceableEventDispatcher opens a section with the Stopwatch, which never gets closed.
This causes a \LogicException when measuring the time of something with an internal requests.
How to reproduce
$stopwatch->start('foo');// do something with an internal request:$kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST,false);$stopwatch->stop('foo');
--> yields\LogicException('Event "foo" is not started.') in the last line
Possible Solution
CallstopSection even if no'X-Debug-Token' is set in the response headers.
The route name might be a neat fallback:
$token =$event->getResponse()->headers->get('X-Debug-Token',$event->getRequest()->attributes->get('_route'));
The TraceableEventDispatcher starts the section, it should be responsible for it being closed again, no matter what.
Additional context
This happens running a functional test with phpunit with debug enabled.
The only place where'X-Debug-Token' is set seems to be the Profiler - which is probably not enabled during unit tests (at least for us).