Socket
Socket
Sign inDemoInstall

sqs-consumer

Package Overview
Dependencies
2
Maintainers
2
Versions
91
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.0.0 to 8.1.0

1

dist/consumer.d.ts

@@ -19,2 +19,3 @@ import { ConsumerOptions, StopOptions, UpdatableOptions } from './types';

private shouldDeleteMessages;
private alwaysAcknowledge;
private batchSize;

@@ -21,0 +22,0 @@ private visibilityTimeout;

11

dist/consumer.js

@@ -15,3 +15,3 @@ "use strict";

constructor(options) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e;
super();

@@ -39,2 +39,3 @@ this.pollingTimeoutId = undefined;

this.shouldDeleteMessages = (_d = options.shouldDeleteMessages) !== null && _d !== void 0 ? _d : true;
this.alwaysAcknowledge = (_e = options.alwaysAcknowledge) !== null && _e !== void 0 ? _e : false;
this.sqs =

@@ -351,3 +352,5 @@ options.sqs ||

}
return result instanceof Object ? result : message;
return !this.alwaysAcknowledge && result instanceof Object
? result
: message;
}

@@ -376,3 +379,5 @@ catch (err) {

const result = await this.handleMessageBatch(messages);
return result instanceof Object ? result : messages;
return !this.alwaysAcknowledge && result instanceof Object
? result
: messages;
}

@@ -379,0 +384,0 @@ catch (err) {

@@ -87,2 +87,10 @@ import { SQSClient, Message, QueueAttributeName } from '@aws-sdk/client-sqs';

/**
* By default, the consumer will treat an empty object or array from either of the
* handlers as a acknowledgement of no messages and will not delete those messages as
* a result. Set this to `true` to always acknowledge all messages no matter the returned
* value.
* @defaultvalue `false`
*/
alwaysAcknowledge?: boolean;
/**
* An `async` function (or function that returns a `Promise`) to be called whenever

@@ -89,0 +97,0 @@ * a message is received.

{
"name": "sqs-consumer",
"version": "8.0.0",
"version": "8.1.0",
"description": "Build SQS-based Node applications without the boilerplate",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -53,6 +53,10 @@ # sqs-consumer

- The queue is polled continuously for messages using [long polling](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.html).
- Messages are deleted from the queue once the handler function has completed successfully.
- 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](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html) can be used to move messages that cannot be processed to a dead letter queue.
- By default messages are processed one at a time – a new message won't be received until the first one has been processed. To process messages in parallel, use the `batchSize` option [detailed below](#options).
- By default, messages that are sent to the `handleMessage` and `handleMessageBatch` functions will be considered as processed if they return without an error. To acknowledge individual messages, please return the message that you want to acknowledge if you are using `handleMessage` or the messages for `handleMessageBatch`. It's also important to await any processing that you are doing to ensure that messages are processed one at a time.
- By default messages are processed one at a time – a new message won't be received until the first one has been processed. To process messages in parallel, use the `batchSize` option [detailed here](https://bbc.github.io/sqs-consumer/interfaces/ConsumerOptions.html#batchSize).
- It's also important to await any processing that you are doing to ensure that messages are processed one at a time.
- By default, messages that are sent to the `handleMessage` and `handleMessageBatch` functions will be considered as processed if they return without an error.
- To acknowledge individual messages, please return the message that you want to acknowledge if you are using `handleMessage` or the messages for `handleMessageBatch`.
- To note, returning an empty object or an empty array will be considered an acknowledgement of no message(s) and will result in no messages being deleted. If you would like to change this behaviour, please use the `alwaysAcknowledge` option [detailed here](https://bbc.github.io/sqs-consumer/interfaces/ConsumerOptions.html).
- By default, if an object or an array is not returned, all messages will be acknowledged.
- Messages are deleted from the queue once the handler function has completed successfully (the above items should also be taken into account).

@@ -59,0 +63,0 @@ ### Credentials

@@ -50,2 +50,3 @@ import {

private shouldDeleteMessages: boolean;
private alwaysAcknowledge: boolean;
private batchSize: number;

@@ -81,2 +82,3 @@ private visibilityTimeout: number;

this.shouldDeleteMessages = options.shouldDeleteMessages ?? true;
this.alwaysAcknowledge = options.alwaysAcknowledge ?? false;
this.sqs =

@@ -458,3 +460,5 @@ options.sqs ||

return result instanceof Object ? result : message;
return !this.alwaysAcknowledge && result instanceof Object
? result
: message;
} catch (err) {

@@ -488,3 +492,5 @@ if (err instanceof TimeoutError) {

return result instanceof Object ? result : messages;
return !this.alwaysAcknowledge && result instanceof Object
? result
: messages;
} catch (err) {

@@ -491,0 +497,0 @@ if (err instanceof Error) {

@@ -88,2 +88,10 @@ import { SQSClient, Message, QueueAttributeName } from '@aws-sdk/client-sqs';

/**
* By default, the consumer will treat an empty object or array from either of the
* handlers as a acknowledgement of no messages and will not delete those messages as
* a result. Set this to `true` to always acknowledge all messages no matter the returned
* value.
* @defaultvalue `false`
*/
alwaysAcknowledge?: boolean;
/**
* An `async` function (or function that returns a `Promise`) to be called whenever

@@ -90,0 +98,0 @@ * a message is received.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc