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 7.1.0 to 7.2.0-canary.1

dist/emitter.d.ts

3

dist/consumer.d.ts

@@ -1,2 +0,3 @@

import { ConsumerOptions, TypedEventEmitter, StopOptions, UpdatableOptions } from './types';
import { ConsumerOptions, StopOptions, UpdatableOptions } from './types';
import { TypedEventEmitter } from './emitter';
/**

@@ -3,0 +4,0 @@ * [Usage](https://bbc.github.io/sqs-consumer/index.html#usage)

@@ -5,4 +5,3 @@ "use strict";

const client_sqs_1 = require("@aws-sdk/client-sqs");
const debug_1 = require("debug");
const types_1 = require("./types");
const emitter_1 = require("./emitter");
const bind_1 = require("./bind");

@@ -12,7 +11,7 @@ const errors_1 = require("./errors");

const controllers_1 = require("./controllers");
const debug = (0, debug_1.default)('sqs-consumer');
const logger_1 = require("./logger");
/**
* [Usage](https://bbc.github.io/sqs-consumer/index.html#usage)
*/
class Consumer extends types_1.TypedEventEmitter {
class Consumer extends emitter_1.TypedEventEmitter {
constructor(options) {

@@ -64,3 +63,3 @@ var _a, _b, _c, _d;

if (this.stopped) {
debug('Starting consumer');
logger_1.logger.debug('starting');
this.stopped = false;

@@ -76,6 +75,6 @@ this.emit('started');

if (this.stopped) {
debug('Consumer was already stopped');
logger_1.logger.debug('already_stopped');
return;
}
debug('Stopping consumer');
logger_1.logger.debug('stopping');
this.stopped = true;

@@ -87,3 +86,3 @@ if (this.pollingTimeoutId) {

if (options === null || options === void 0 ? void 0 : options.abort) {
debug('Aborting SQS requests');
logger_1.logger.debug('aborting');
controllers_1.abortController.abort();

@@ -107,3 +106,2 @@ this.emit('aborted');

(0, validation_1.validateOption)(option, value, this, true);
debug(`Updating the ${option} option to the value ${value}`);
this[option] = value;

@@ -136,6 +134,8 @@ this.emit('option_updated', option, value);

if (this.stopped) {
debug('Poll was called while consumer was stopped, cancelling poll...');
logger_1.logger.debug('cancelling_poll', {
detail: 'Poll was called while consumer was stopped, cancelling poll...'
});
return;
}
debug('Polling for messages');
logger_1.logger.debug('polling');
let currentPollingTimeout = this.pollingWaitTimeMs;

@@ -154,3 +154,5 @@ this.receiveMessage({

if ((0, errors_1.isConnectionError)(err)) {
debug('There was an authentication error. Pausing before retrying.');
logger_1.logger.debug('authentication_error', {
detail: 'There was an authentication error. Pausing before retrying.'
});
currentPollingTimeout = this.authenticationErrorTimeout;

@@ -189,2 +191,7 @@ }

if ((0, validation_1.hasMessages)(response)) {
const handlerProcessingDebugger = setInterval(() => {
logger_1.logger.debug('handler_processing', {
detail: 'The handler is still processing the message(s)...'
});
}, 1000);
if (this.handleMessageBatch) {

@@ -196,2 +203,3 @@ await this.processMessageBatch(response.Messages);

}
clearInterval(handlerProcessingDebugger);
this.emit('response_processed');

@@ -228,3 +236,5 @@ }

finally {
clearInterval(heartbeatTimeoutId);
if (this.heartbeatInterval) {
clearInterval(heartbeatTimeoutId);
}
}

@@ -370,6 +380,8 @@ }

if (!this.shouldDeleteMessages) {
debug('Skipping message delete since shouldDeleteMessages is set to false');
logger_1.logger.debug('skipping_delete', {
detail: 'Skipping message delete since shouldDeleteMessages is set to false'
});
return;
}
debug('Deleting message %s', message.MessageId);
logger_1.logger.debug('deleting_message', { messageId: message.MessageId });
const deleteParams = {

@@ -392,6 +404,10 @@ QueueUrl: this.queueUrl,

if (!this.shouldDeleteMessages) {
debug('Skipping message delete since shouldDeleteMessages is set to false');
logger_1.logger.debug('skipping_delete', {
detail: 'Skipping message delete since shouldDeleteMessages is set to false'
});
return;
}
debug('Deleting messages %s', messages.map((msg) => msg.MessageId).join(' ,'));
logger_1.logger.debug('deleting_messages', {
messageIds: messages.map((msg) => msg.MessageId)
});
const deleteParams = {

@@ -398,0 +414,0 @@ QueueUrl: this.queueUrl,

@@ -1,4 +0,2 @@

/// <reference types="node" />
import { SQSClient, Message } from '@aws-sdk/client-sqs';
import { EventEmitter } from 'events';
export interface ConsumerOptions {

@@ -166,21 +164,2 @@ /**

}
export declare class TypedEventEmitter extends EventEmitter {
/**
* Trigger a listener on all emitted events
* @param event The name of the event to listen to
* @param listener A function to trigger when the event is emitted
*/
on<E extends keyof Events>(event: E, listener: (...args: Events[E]) => void): this;
/**
* Trigger a listener only once for an emitted event
* @param event The name of the event to listen to
* @param listener A function to trigger when the event is emitted
*/
once<E extends keyof Events>(event: E, listener: (...args: Events[E]) => void): this;
/**
* Emits an event with the provided arguments
* @param event The name of the event to emit
*/
emit<E extends keyof Events>(event: E, ...args: Events[E]): boolean;
}
export type AWSError = {

@@ -187,0 +166,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypedEventEmitter = void 0;
const events_1 = require("events");
class TypedEventEmitter extends events_1.EventEmitter {
/**
* Trigger a listener on all emitted events
* @param event The name of the event to listen to
* @param listener A function to trigger when the event is emitted
*/
on(event, listener) {
return super.on(event, listener);
}
/**
* Trigger a listener only once for an emitted event
* @param event The name of the event to listen to
* @param listener A function to trigger when the event is emitted
*/
once(event, listener) {
return super.once(event, listener);
}
/**
* Emits an event with the provided arguments
* @param event The name of the event to emit
*/
emit(event, ...args) {
return super.emit(event, ...args);
}
}
exports.TypedEventEmitter = TypedEventEmitter;
{
"name": "sqs-consumer",
"version": "7.1.0",
"version": "7.2.0-canary.1",
"description": "Build SQS-based Node applications without the boilerplate",

@@ -46,3 +46,2 @@ "main": "dist/index.js",

"@types/chai": "^4.3.4",
"@types/debug": "^4.1.7",
"@types/mocha": "^10.0.1",

@@ -49,0 +48,0 @@ "@types/node": "^18.11.18",

@@ -18,10 +18,5 @@ import {

} from '@aws-sdk/client-sqs';
import Debug from 'debug';
import {
ConsumerOptions,
TypedEventEmitter,
StopOptions,
UpdatableOptions
} from './types';
import { ConsumerOptions, StopOptions, UpdatableOptions } from './types';
import { TypedEventEmitter } from './emitter';
import { autoBind } from './bind';

@@ -36,5 +31,4 @@ import {

import { abortController } from './controllers';
import { logger } from './logger';
const debug = Debug('sqs-consumer');
/**

@@ -101,3 +95,3 @@ * [Usage](https://bbc.github.io/sqs-consumer/index.html#usage)

if (this.stopped) {
debug('Starting consumer');
logger.debug('starting');
this.stopped = false;

@@ -114,7 +108,7 @@ this.emit('started');

if (this.stopped) {
debug('Consumer was already stopped');
logger.debug('already_stopped');
return;
}
debug('Stopping consumer');
logger.debug('stopping');
this.stopped = true;

@@ -128,6 +122,4 @@

if (options?.abort) {
debug('Aborting SQS requests');
logger.debug('aborting');
abortController.abort();
this.emit('aborted');

@@ -157,4 +149,2 @@ }

debug(`Updating the ${option} option to the value ${value}`);
this[option] = value;

@@ -194,7 +184,9 @@

if (this.stopped) {
debug('Poll was called while consumer was stopped, cancelling poll...');
logger.debug('cancelling_poll', {
detail: 'Poll was called while consumer was stopped, cancelling poll...'
});
return;
}
debug('Polling for messages');
logger.debug('polling');

@@ -214,3 +206,6 @@ let currentPollingTimeout = this.pollingWaitTimeMs;

if (isConnectionError(err)) {
debug('There was an authentication error. Pausing before retrying.');
logger.debug('authentication_error', {
detail:
'There was an authentication error. Pausing before retrying.'
});
currentPollingTimeout = this.authenticationErrorTimeout;

@@ -257,2 +252,8 @@ }

if (hasMessages(response)) {
const handlerProcessingDebugger = setInterval(() => {
logger.debug('handler_processing', {
detail: 'The handler is still processing the message(s)...'
});
}, 1000);
if (this.handleMessageBatch) {

@@ -264,2 +265,4 @@ await this.processMessageBatch(response.Messages);

clearInterval(handlerProcessingDebugger);
this.emit('response_processed');

@@ -300,3 +303,5 @@ } else if (response) {

} finally {
clearInterval(heartbeatTimeoutId);
if (this.heartbeatInterval) {
clearInterval(heartbeatTimeoutId);
}
}

@@ -476,8 +481,9 @@ }

if (!this.shouldDeleteMessages) {
debug(
'Skipping message delete since shouldDeleteMessages is set to false'
);
logger.debug('skipping_delete', {
detail:
'Skipping message delete since shouldDeleteMessages is set to false'
});
return;
}
debug('Deleting message %s', message.MessageId);
logger.debug('deleting_message', { messageId: message.MessageId });

@@ -505,11 +511,11 @@ const deleteParams: DeleteMessageCommandInput = {

if (!this.shouldDeleteMessages) {
debug(
'Skipping message delete since shouldDeleteMessages is set to false'
);
logger.debug('skipping_delete', {
detail:
'Skipping message delete since shouldDeleteMessages is set to false'
});
return;
}
debug(
'Deleting messages %s',
messages.map((msg) => msg.MessageId).join(' ,')
);
logger.debug('deleting_messages', {
messageIds: messages.map((msg) => msg.MessageId)
});

@@ -516,0 +522,0 @@ const deleteParams: DeleteMessageBatchCommandInput = {

import { SQSClient, Message } from '@aws-sdk/client-sqs';
import { EventEmitter } from 'events';

@@ -173,34 +172,2 @@ export interface ConsumerOptions {

export class TypedEventEmitter extends EventEmitter {
/**
* Trigger a listener on all emitted events
* @param event The name of the event to listen to
* @param listener A function to trigger when the event is emitted
*/
on<E extends keyof Events>(
event: E,
listener: (...args: Events[E]) => void
): this {
return super.on(event, listener);
}
/**
* Trigger a listener only once for an emitted event
* @param event The name of the event to listen to
* @param listener A function to trigger when the event is emitted
*/
once<E extends keyof Events>(
event: E,
listener: (...args: Events[E]) => void
): this {
return super.once(event, listener);
}
/**
* Emits an event with the provided arguments
* @param event The name of the event to emit
*/
emit<E extends keyof Events>(event: E, ...args: Events[E]): boolean {
return super.emit(event, ...args);
}
}
export type AWSError = {

@@ -207,0 +174,0 @@ /**

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