Skip to content

Commit

Permalink
feat: add NonExistentQueue to isConnectionError (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasgriffintn authored Dec 17, 2022
1 parent c170e0d commit d6866ed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ function isConnectionError(err: Error): boolean {
return (
err.statusCode === 403 ||
err.code === 'CredentialsError' ||
err.code === 'UnknownEndpoint'
err.code === 'UnknownEndpoint' ||
err.code === 'AWS.SimpleQueueService.NonExistentQueue'
);
}
return false;
Expand Down
19 changes: 19 additions & 0 deletions test/consumer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,25 @@ describe('Consumer', () => {
sandbox.assert.calledWithMatch(sqs.send.secondCall, mockReceiveMessage);
});

it('waits before repolling when a NonExistentQueue error occurs', async () => {
const nonExistentQueueErr = {
name: 'AWS.SimpleQueueService.NonExistentQueue',
message: 'The specified queue does not exist for this wsdl version.'
};
sqs.send.withArgs(mockReceiveMessage).rejects(nonExistentQueueErr);
const errorListener = sandbox.stub();
consumer.on('error', errorListener);

consumer.start();
await clock.tickAsync(AUTHENTICATION_ERROR_TIMEOUT);
consumer.stop();

sandbox.assert.calledTwice(errorListener);
sandbox.assert.calledTwice(sqs.send);
sandbox.assert.calledWithMatch(sqs.send.firstCall, mockReceiveMessage);
sandbox.assert.calledWithMatch(sqs.send.secondCall, mockReceiveMessage);
});

it('waits before repolling when a polling timeout is set', async () => {
consumer = new Consumer({
queueUrl: QUEUE_URL,
Expand Down

0 comments on commit d6866ed

Please sign in to comment.