Closed nicholasgriffintn closed 1 year ago
Resolves: #234
Follow up from: https://github.com/bbc/sqs-consumer/pull/298, without the abort functionality, just the timeout.
.stop()
As consumer does not clear the timeout, when calling start, stop and then start:
// eslint-disable-next-line no-console console.log('STARTING SQS CONSUMER'); consumer.start(); // eslint-disable-next-line no-console console.log('STOPPING SQS CONSUMER'); consumer.stop(); // eslint-disable-next-line no-console console.log('STARTING SQS CONSUMER'); consumer.start();
Consumer effectively calls everything twice, as the timeout is still running from the original consumer instance, as shown below (two Polling for messages logs):
Polling for messages
STARTING SQS CONSUMER sqs-consumer Starting consumer +0ms sqs-consumer Polling for messages +0ms STOPPING SQS CONSUMER sqs-consumer Stopping consumer +2ms RECEIVED SQS STOPPED: STARTING SQS CONSUMER sqs-consumer Starting consumer +0ms sqs-consumer Polling for messages +0ms EXPRESS APP LISTENING ON: http://localhost:3026 sqs-consumer Received SQS response +20s sqs-consumer { sqs-consumer '$metadata': { sqs-consumer httpStatusCode: 200, sqs-consumer requestId: undefined, sqs-consumer extendedRequestId: undefined, sqs-consumer cfId: undefined, sqs-consumer attempts: 1, sqs-consumer totalRetryDelay: 0 sqs-consumer }, sqs-consumer Messages: undefined sqs-consumer } +1ms RECEIVED SQS EMPTY: sqs-consumer Received SQS response +2ms sqs-consumer { sqs-consumer '$metadata': { sqs-consumer httpStatusCode: 200, sqs-consumer requestId: undefined, sqs-consumer extendedRequestId: undefined, sqs-consumer cfId: undefined, sqs-consumer attempts: 1, sqs-consumer totalRetryDelay: 0 sqs-consumer }, sqs-consumer Messages: undefined sqs-consumer } +0ms RECEIVED SQS EMPTY: sqs-consumer Polling for messages +1ms sqs-consumer Polling for messages +2ms
Resolves: #234
Follow up from: https://github.com/bbc/sqs-consumer/pull/298, without the abort functionality, just the timeout.
Changes
.stop()
is calledThe issue
As consumer does not clear the timeout, when calling start, stop and then start:
Consumer effectively calls everything twice, as the timeout is still running from the original consumer instance, as shown below (two
Polling for messages
logs):