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

Thrown error inside batch message handler kills app. #29

Open
cberiganTAG opened this issue Jun 23, 2022 · 3 comments
Open

Thrown error inside batch message handler kills app. #29

cberiganTAG opened this issue Jun 23, 2022 · 3 comments

Comments

@cberiganTAG
Copy link

Whenever an error is thrown inside a batch message handler and there is no error event handler method, an uncaught exception is thrown and kills the app.

Steps to reproduce:

  1. Set up handler like so:
@SqsMessageHandler('test', true)
public async handleMessage(messages: SQS.Message[]): Promise<void> {
  throw new Error('test')
}
  1. Do NOT include @SqsConsumerEventHandler('test', 'error').

It seems like when I include the error event handler, the error is able to be caught and logged. The app continues to run.

Expectation:

The error event handler should be an opt-in feature. The app should continue to function if individual handlers fail for whatever reason.

Results:

Throws uncaught exception

[1656014764276] ERROR: Error: Unexpected message handler failure: test
    at RentlyWebhookSqsHandler.handleMessage (C:\SourceControl\GITHUB\everest\backend\src\rently\sqs-handlers\rently-webhook-sqs-handler.service.ts:27:11)
    at Consumer.executeBatchHandler (C:\SourceControl\GITHUB\everest\backend\node_modules\@ssut\nestjs-sqs\node_modules\sqs-consumer\dist\consumer.js:303:24)
    at Consumer.processMessageBatch (C:\SourceControl\GITHUB\everest\backend\node_modules\@ssut\nestjs-sqs\node_modules\sqs-consumer\dist\consumer.js:267:24)
    at Consumer.handleSqsResponse (C:\SourceControl\GITHUB\everest\backend\node_modules\@ssut\nestjs-sqs\node_modules\sqs-consumer\dist\consumer.js:113:32)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Also terminates the app.

@cberiganTAG
Copy link
Author

cberiganTAG commented Jun 23, 2022

I think the necessary fix would be to have a default error listener on all consumers if one is not provided OR the sqs-consumer package should be emitting processing_error instead of error on batch message handlers throw errors.

@n05la3
Copy link

n05la3 commented Jan 24, 2023

This issue is related to #9

@PetrShchukin
Copy link

The issue is not with @ssut/nestjs-sqs. I am getting the same error using sqs-consumer package

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

No branches or pull requests

3 participants