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]: heartbeatInterval is not working as expected #376

Closed rishi-aga closed 1 year ago

rishi-aga commented 1 year ago

Describe the bug

heartbeatInterval is not cleared for all the messages, this is causing error events after the message is successfully processed.

possible fix: https://github.com/bbc/sqs-consumer/pull/375/files

Your minimal, reproducible example

See steps to reproduce.

Steps to reproduce

  1. Use batchSize > 1, set heartbeatInterval and handleMessage for processing the message.
  2. Add 2 messages to your queue while the app is not running
  3. start the app
  4. app successfully processes both messages in parallel.
  5. app only clears heartbeatInterval for one of the messages. For other messages, it emits:
    "error": {
        "code": "InvalidParameterValue",
        "fault": "client",
        "name": "SQSError",
        "statusCode": 400,
        "time": "2023-03-16T14:54:53.367Z"
    }

Expected behavior

It should not be emitting error events after the message is successfully processed.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Package version

^7.0.2

AWS SDK version

^3.258.0

Additional context

No response

nicholasgriffintn commented 1 year ago

This definitely needs some sort of investigation as to why, we've not been made aware of any such issues in the past.

We'd probably first want some sort of failing test to work out if this is actually an issue with the consumer (would be e2e), then work from there until the test passes. It's possible that this is due to something external.

Edit: After looking more into it, I think it might be that we made heartbeat interval id a global variable and your change would actually resolve this, as this was how it was originally implemented.

rishi-aga commented 1 year ago

Thanks @nicholasgriffintn

github-actions[bot] commented 1 year 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.