@@ -93,12 +93,13 @@ export class Consumer extends TypedEventEmitter {
9393 this . alwaysAcknowledge = options . alwaysAcknowledge ?? false ;
9494 this . extendedAWSErrors = options . extendedAWSErrors ?? false ;
9595 this . strictReturn = options . strictReturn ?? false ;
96- this . sqs =
97- options . sqs ||
98- new SQSClient ( {
99- useQueueUrlAsEndpoint : options . useQueueUrlAsEndpoint ?? true ,
100- region : options . region || process . env . AWS_REGION || "eu-west-1" ,
101- } ) ;
96+ if ( options . sqs ) {
97+ this . sqs = options . sqs ;
98+ } else {
99+ const useQueueUrlAsEndpoint = options . useQueueUrlAsEndpoint ?? true ;
100+ const region = options . region || process . env . AWS_REGION || "eu-west-1" ;
101+ this . sqs = new SQSClient ( { useQueueUrlAsEndpoint, region } ) ;
102+ }
102103 }
103104
104105 /**
@@ -131,10 +132,12 @@ export class Consumer extends TypedEventEmitter {
131132 * A reusable options object for sqs.send that's used to avoid duplication.
132133 */
133134 private get sqsSendOptions ( ) : { abortSignal : AbortSignal } {
135+ const abortSignal = this . abortController ?. signal || new AbortController ( ) . signal ;
136+
134137 return {
135138 // return the current abortController signal or a fresh signal that has not been aborted.
136139 // This effectively defaults the signal sent to the AWS SDK to not aborted
137- abortSignal : this . abortController ?. signal || new AbortController ( ) . signal ,
140+ abortSignal,
138141 } ;
139142 }
140143
@@ -261,13 +264,15 @@ export class Consumer extends TypedEventEmitter {
261264 try {
262265 this . emitError ( err ) ;
263266 } catch ( listenerErr ) {
264- logger . warn (
265- `An error event listener threw an error: ${ listenerErr instanceof Error ? listenerErr . message : String ( listenerErr ) } ` ,
266- ) ;
267+ const listenerErrorMessage =
268+ listenerErr instanceof Error ? listenerErr . message : String ( listenerErr ) ;
269+ logger . warn ( `An error event listener threw an error: ${ listenerErrorMessage } ` ) ;
267270 }
268271 if ( isConnectionError ( err ) ) {
272+ const errorCode = err . code || "Unknown" ;
273+
269274 logger . debug ( "authentication_error" , {
270- code : err . code || "Unknown" ,
275+ code : errorCode ,
271276 detail : "There was an authentication error. Pausing before retrying." ,
272277 } ) ;
273278 currentPollingTimeout = this . authenticationErrorTimeout ;
0 commit comments