bbc / sqs-consumer

Build Amazon Simple Queue Service (SQS) based applications without the boilerplate
https://bbc.github.io/sqs-consumer/
Other
1.71k stars 330 forks source link

[Bug]: When consumer fails to react to SQS instant retry occurs #484

Closed fraserbenjamin closed 2 months ago

fraserbenjamin commented 3 months ago

Describe the bug

If the consumer cannot connect to SQS due to no internet connection or the unlikely event SQS is down, if pollingWaitTimeMs is 0 (set by default), it will instantly retry the connection causing a continual flurry of requests. There is currently no option to resolve this other than by setting pollingWaitTimeMs to a higher value however this also isn't ideal since it adds a longer wait between polls too. Currently authentication errors are caught and can have a back-off configured with authenticationErrorTimeout though this doesn't exist for general connection errors.

Your minimal, reproducible example

https://stackblitz.com/github/fraserbenjamin/sqs-consumer-starter?file=index.js

Steps to reproduce

Once the application starts you will see the console quickly filled up with error messages saying Could not load credentials from any providers, although if you had credentials available it would then say SQS receive message failed: The specified queue does not exist and if there was a connectivity issue you would get SQS receive message failed: getaddrinfo ENOTFOUND sqs.eu-central-1.amazonaws.com

Expected behavior

As a user I expected these retries to be throttled after a failure but instead I see requests continuously being made and error messages being sent to the console at an excessive rate.

How often does this bug happen?

Every time

Screenshots or Videos

Screenshot 2024-04-04 at 08 49 41

Platform

Occurs on all platforms and tested with the issue happening on Node versions 16-20.

Package version

9.1.0

AWS SDK version

3.547.0

Additional context

No response

fraserbenjamin commented 3 months ago

I've created a PR to resolve this issue here https://github.com/bbc/sqs-consumer/pull/485

github-actions[bot] commented 2 months ago

:tada: This issue has been resolved in version 10.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 month ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.