sqs-consumer
sqs-consumer copied to clipboard
Heartbeat interval timer race condition on delete message
Describe the bug On occasion, the changeMessageVisibility can be called right after the message has been deleted.
To Reproduce Set the heartbeatInterval and hope to reproduce the issue.
Expected behaviour The heartbeat timer should be cleared before the message is deleted.
screenshots Logs:
(node:79) UnhandledPromiseRejectionWarning: InvalidParameterValue: Value AQEBLx0X8FnUWHcy3y4153jNAlLz++lScChMuHLfsPkUrq3HmVo30Kj857VIS8WL9yierpGSZAhFQWkSioB9kSF1huOdz2AM37DRIEVouwoxjRwUz7x+b+ihMSvTEsEh2BpJrxrVHYaqlaSz+KX4Q47sFc4ZpQ1zeiLXzb0y+89bmnKHhUexCTIzwh/PW4R1HzbvJJ+B6pOowKo+2UXzwjtFj2fbRmHJSqypt7fYQaafSyHRRo5hcEkKDLERTyFy/x8JpaiCUIC6UAVCLE/Aqo1w7j4ydos2uC6+TbDZAv9PWFw= for parameter ReceiptHandle is invalid. Reason: Message does not exist or is not available for visibility timeout change.
at Request.extractError (/node_modules/aws-sdk/lib/protocol/query.js:50:29)
at Request.callListeners (/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/node_modules/aws-sdk/lib/request.js:688:14)
at Request.transition (/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/node_modules/aws-sdk/lib/request.js:690:12)
at Request.callListeners (/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
(node:79) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:79) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Additional context
clearInterval(heartbeat)
should be called in two places:
- https://github.com/bbc/sqs-consumer/blob/3cafbb7e2b4847e3afbd6ebb3cc17bbc6faceb09/src/consumer.ts#L211
- https://github.com/bbc/sqs-consumer/blob/3cafbb7e2b4847e3afbd6ebb3cc17bbc6faceb09/src/consumer.ts#L211
I have the same issue. Have you found the solution?
The unhandled rejection might be fixed when solving #275
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
As suggested, https://github.com/bbc/sqs-consumer/issues/275 might have fixed this, please reopen if it didn't.