You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MultiplierRetryStrategy multiplies a float with an integer which results in a float, however, the function expects an int.
This causes the code to fail.
How to reproduce
messenger.yaml
fifo:
dsn: '%env(DSN_OF_SQS_FIFO_QUEUE)%'
retry_strategy:
delay: 0 # This is necessary as per the Symfony documentation
Fail a message with a RecoverableExceptionInterface, and you should get the failure Symfony\Component\Messenger\Retry\MultiplierRetryStrategy::getWaitingTime(): Return value must be of type int, float returned
Possible Solution
The issue is here in the code \Symfony\Component\Messenger\Retry\MultiplierRetryStrategy::getWaitingTime
We could round up or down the $delay before sending it back, that way the interface is preserved.
Additional Context
Exception
{
"class":"TypeError",
"message":"Symfony\\Component\\Messenger\\Retry\\MultiplierRetryStrategy::getWaitingTime(): Return value must be of type int, float returned",
"code":0,
"file":"/application/vendor/symfony/messenger/Retry/MultiplierRetryStrategy.php:89",
"trace":[
"/application/vendor/symfony/messenger/EventListener/SendFailedMessageForRetryListener.php:70",
"/application/vendor/symfony/event-dispatcher/EventDispatcher.php:270",
"/application/vendor/symfony/event-dispatcher/EventDispatcher.php:230",
"/application/vendor/symfony/event-dispatcher/EventDispatcher.php:59",
"/application/vendor/symfony/messenger/Worker.php:192",
"/application/vendor/symfony/messenger/Worker.php:168",
"/application/vendor/symfony/messenger/Worker.php:105",
"/application/vendor/symfony/messenger/Command/ConsumeMessagesCommand.php:223",
"/application/vendor/symfony/console/Command/Command.php:298",
"/application/vendor/symfony/console/Application.php:1042",
"/application/vendor/symfony/framework-bundle/Console/Application.php:94",
"/application/vendor/symfony/console/Application.php:299",
"/application/vendor/symfony/framework-bundle/Console/Application.php:80",
"/application/vendor/symfony/console/Application.php:171",
"/application/bin/console:38"
]
}```
The text was updated successfully, but these errors were encountered:
WissameMekhilef
changed the title
Messenger Component - MultiplierRetryStrategy - Return value must be of type int, float returned
[Messenger] - MultiplierRetryStrategy - Return value must be of type int, float returned
Jun 28, 2022
WissameMekhilef
changed the title
[Messenger] - MultiplierRetryStrategy - Return value must be of type int, float returned
[Messenger] MultiplierRetryStrategy - Return value must be of type int, float returned
Jun 28, 2022
…n retry (WissameMekhilef)
This PR was submitted for the 6.1 branch but it was squashed and merged into the 4.4 branch instead.
Discussion
----------
[Messenger] Ceil waiting time when multiplier is a float on retry
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | #46795
| License | MIT
| Doc PR | Not required
In the Messenger - MultiplierRetryStrategy the return type for the function `getWaitingTime` is int, however with the computation of that function we were returning a float, this is because float * int returns a float and the attribute $multiplier is a float.
With this fix, we are rounding up the delay and casting into an int.
Commits
-------
3b62a06 [Messenger] Ceil waiting time when multiplier is a float on retry
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
6.1
Description
The
MultiplierRetryStrategy
multiplies a float with an integer which results in a float, however, the function expects an int.This causes the code to fail.
How to reproduce
messenger.yaml
Fail a message with a
RecoverableExceptionInterface
, and you should get the failureSymfony\Component\Messenger\Retry\MultiplierRetryStrategy::getWaitingTime(): Return value must be of type int, float returned
Possible Solution
The issue is here in the code
\Symfony\Component\Messenger\Retry\MultiplierRetryStrategy::getWaitingTime
We could round up or down the $delay before sending it back, that way the interface is preserved.
Additional Context
Exception
The text was updated successfully, but these errors were encountered: