sqs-consumer
sqs-consumer copied to clipboard
`handleMessage` type check on thrown errors
Describe the bug According to usage docs:
Throwing an error (or returning a rejected promise) from the handler function will cause the message to be left on the queue. An SQS redrive policy can be used to move messages that cannot be processed to a dead letter queue.
It appears that the handleMessage
and handleMessageBatch
type definitions specify Promise<void>
instead of Promise<void | Error>
.
Supplying a handleMessage
function that throws errors results in:
TS2345: Argument of type '(message: Message) => Promise<Error>' is not assignable to parameter of type '(message: Message) => Promise
'. Type 'Promise<Error>' is not assignable to type 'Promise '. Type 'Error' is not assignable to type 'void'.
To Reproduce Steps to reproduce the behaviour:
- Define a
handleMessage
function with throws an error. - Pass said function into
Consumer.create({ ..., handleMessage })
Expected behaviour
Passing a handleMessage
function that throws errors should not result in type check errors.