Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heartbeat errors are not propagated / catched #275

Closed
michaelwittig opened this issue Sep 7, 2021 · 2 comments
Closed

Heartbeat errors are not propagated / catched #275

michaelwittig opened this issue Sep 7, 2021 · 2 comments
Labels

Comments

@michaelwittig
Copy link
Contributor

Describe the bug
If the call to changeVisabilityTimeout fails, the Promise is rejected but no one notices. Node.js complains about this with an

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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

To Reproduce
Steps to reproduce the behaviour:

  1. I was running into this because of a missing IAM permission Fix documented required IAM actions #274 and I think that is the easiest way to reproduce the issue

Expected behaviour
I'm not sure but it could be an error event?

I'm willing to provide a fix if we can agree on what's expected.

@rafael-pb
Copy link
Contributor

I believe I had a similar issue in my application. The stack trace didn't help, but my application got killed due to unhandled exception/rejection (my app is configured to die if such thing happen). The reason was changeMessageVisibility call that failed.

By inspecting the code of sqs-consumer, I believe the reason is that inside the methods changeVisabilityTimeoutBatch and changeVisabilityTimeout they do not "await" the promise; therefore the try {} catch {} does not catch the error. It also happens because those who call it do not catch any errors (one is inside a timer and the other is inside a catch block).

I believe adding the await should fix the issue.

rafael-pb added a commit to rafael-pb/sqs-consumer that referenced this issue Oct 13, 2021
memsb pushed a commit that referenced this issue Apr 14, 2022
Issue #275 - Fix visibility timeout error handler
@michaelwittig
Copy link
Contributor Author

the issue is fixed. Thanks @rafael-pb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants