Description
Symfony version(s) affected: 4.4, 5.0, 5.1
Description
In certain cases when TraceableMiddleware
is used, LogicException
from Stopwatch is thrown because TraceableMiddleware
tries to stop an event that is not started.
How to reproduce
Repo available here https://github.com/jlekowski/symfony-messenger-traceablemiddleware - clone and try to add and consume a message by calling messages:
php bin/console notification:send
php bin/console messenger:consume
result:
2020-05-08T15:32:49+01:00 [critical] Error thrown while handling message App\Message\Notification. Removing from transport after 0 retries. Error: "Event ""Symfony\Component\Messenger\Middleware\HandleMessageMiddleware" on "messenger.bus.default"" is not started."
Possible Solution
jlekowski@91c5dbe
Could also be:
$this->stop();
Additional context
There was no issue when redis transport was set (TraceableMiddleware
was not used), or when sub-request was not used.
There is also a chance that my idea of calling sub-requests from a handler is totally wrong, but I believe $this->stopwatch->isStarted($this->currentEvent)
check should be there regardless.