Skip to content

[Messenger] MultiplierRetryStrategy - Return value must be of type int, float returned  #46795

Closed
@WissameMekhilef

Description

@WissameMekhilef

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

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"
   ]
}```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions