Description
Symfony version(s) affected: 4.4|5.0
Description
When the serialization of a message fails a MessageDecodingFailedException
should be thrown.
But this only happens for UnexpectedValueException
in the transport serializer.
This means that any other exceptions from the serializer like MissingConstructorArgumentsException
do not result in a MessageDecodingFailedException
from the messenger transport serializer.
Because this is not the case, the worker crashes and does not reject the message. This also means that the message stays in the queue, resulting in a crash loop of the worker.
How to reproduce
- Create a message in the bus without a worker running.
- Add an extra field to the constructor of the created message
- Run the worker
- Message is not rejected because no
MessageDecodingFailedException
was thrown.
Possible Solution
Instead of checking for Symfony\Component\Serializer\Exception\UnexpectedValueException
check for Symfony\Component\Serializer\Exception\ExceptionInterface
in Symfony\Component\Messenger\Transport\Serialization\Serializer