pass timeout_error event to the message handler function
As a developer, I would like to be able to listen on timeout_error events within my handeMessage function.
Use case
Within handleMessage I have processing that takes (for example) between 1-3 minutes and involves spinning up some memory-intensive child_process.
I decide that I'm going to allow up to 2 minutes for my process to complete. I therefore set my visibilityTimeout to 2 minutes, and my handleMessageTimeout to 1min 55 secs (5s buffer to ensure message cannot be received again, or by another consumer, until properly cancelled).
After 1 min 55 secs, a timeout_error event is emitted. On this event, I would like to cancel my handleMessage processing and kill the child_process. This may take up to 5s to properly kill the process, and then release the message back to the queue to try again.
If the kill is not done, the message will be returned to the queue as expected, but any processing ongoing in the handleMessage will continue in the background for however long it may take. Meanwhile, another message (or worse, another receive of the same message) can be received and begin processing on top. With a CPU-intense process, this could quickly cause the server running sqs-consumer to choke.
I therefore need to be able to listen to the timeout_error from within the handleMessage function.
After reading this, I'm not sure that this is actually functionality to implement, you can listen to timeout_error already within your app, you'll need to add logic within your own app to act on these events.