sqs-consumer 10.0.1 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -3
- package/dist/cjs/consumer.js +1 -0
- package/dist/cjs/errors.js +15 -5
- package/dist/esm/consumer.js +1 -0
- package/dist/esm/errors.js +15 -5
- package/package.json +1 -1
- package/src/consumer.ts +1 -0
- package/src/errors.ts +16 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
## [10.0
|
|
1
|
+
## [10.1.0](https://github.com/bbc/sqs-consumer/compare/v10.0.1...v10.1.0) (2024-04-27)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Features
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* extend authentication error to handle more codes ([#489](https://github.com/bbc/sqs-consumer/issues/489)) ([45f0916](https://github.com/bbc/sqs-consumer/commit/45f09163c086784545e41b8c24ee458d6784bbe7))
|
package/dist/cjs/consumer.js
CHANGED
|
@@ -178,6 +178,7 @@ class Consumer extends emitter_js_1.TypedEventEmitter {
|
|
|
178
178
|
this.emitError(err);
|
|
179
179
|
if ((0, errors_js_1.isConnectionError)(err)) {
|
|
180
180
|
logger_js_1.logger.debug("authentication_error", {
|
|
181
|
+
code: err.code || "Unknown",
|
|
181
182
|
detail: "There was an authentication error. Pausing before retrying.",
|
|
182
183
|
});
|
|
183
184
|
currentPollingTimeout = this.authenticationErrorTimeout;
|
package/dist/cjs/errors.js
CHANGED
|
@@ -23,17 +23,27 @@ class StandardError extends Error {
|
|
|
23
23
|
this.name = "StandardError";
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* List of SQS error codes that are considered connection errors.
|
|
28
|
+
*/
|
|
29
|
+
const CONNECTION_ERRORS = [
|
|
30
|
+
"CredentialsError",
|
|
31
|
+
"UnknownEndpoint",
|
|
32
|
+
"AWS.SimpleQueueService.NonExistentQueue",
|
|
33
|
+
"CredentialsProviderError",
|
|
34
|
+
"InvalidAddress",
|
|
35
|
+
"InvalidSecurity",
|
|
36
|
+
"QueueDoesNotExist",
|
|
37
|
+
"RequestThrottled",
|
|
38
|
+
"OverLimit",
|
|
39
|
+
];
|
|
26
40
|
/**
|
|
27
41
|
* Checks if the error provided should be treated as a connection error.
|
|
28
42
|
* @param err The error that was received.
|
|
29
43
|
*/
|
|
30
44
|
function isConnectionError(err) {
|
|
31
45
|
if (err instanceof SQSError) {
|
|
32
|
-
return
|
|
33
|
-
err.code === "CredentialsError" ||
|
|
34
|
-
err.code === "UnknownEndpoint" ||
|
|
35
|
-
err.code === "AWS.SimpleQueueService.NonExistentQueue" ||
|
|
36
|
-
err.code === "CredentialsProviderError");
|
|
46
|
+
return err.statusCode === 403 || CONNECTION_ERRORS.includes(err.code);
|
|
37
47
|
}
|
|
38
48
|
return false;
|
|
39
49
|
}
|
package/dist/esm/consumer.js
CHANGED
|
@@ -175,6 +175,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
175
175
|
this.emitError(err);
|
|
176
176
|
if (isConnectionError(err)) {
|
|
177
177
|
logger.debug("authentication_error", {
|
|
178
|
+
code: err.code || "Unknown",
|
|
178
179
|
detail: "There was an authentication error. Pausing before retrying.",
|
|
179
180
|
});
|
|
180
181
|
currentPollingTimeout = this.authenticationErrorTimeout;
|
package/dist/esm/errors.js
CHANGED
|
@@ -18,17 +18,27 @@ class StandardError extends Error {
|
|
|
18
18
|
this.name = "StandardError";
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* List of SQS error codes that are considered connection errors.
|
|
23
|
+
*/
|
|
24
|
+
const CONNECTION_ERRORS = [
|
|
25
|
+
"CredentialsError",
|
|
26
|
+
"UnknownEndpoint",
|
|
27
|
+
"AWS.SimpleQueueService.NonExistentQueue",
|
|
28
|
+
"CredentialsProviderError",
|
|
29
|
+
"InvalidAddress",
|
|
30
|
+
"InvalidSecurity",
|
|
31
|
+
"QueueDoesNotExist",
|
|
32
|
+
"RequestThrottled",
|
|
33
|
+
"OverLimit",
|
|
34
|
+
];
|
|
21
35
|
/**
|
|
22
36
|
* Checks if the error provided should be treated as a connection error.
|
|
23
37
|
* @param err The error that was received.
|
|
24
38
|
*/
|
|
25
39
|
function isConnectionError(err) {
|
|
26
40
|
if (err instanceof SQSError) {
|
|
27
|
-
return
|
|
28
|
-
err.code === "CredentialsError" ||
|
|
29
|
-
err.code === "UnknownEndpoint" ||
|
|
30
|
-
err.code === "AWS.SimpleQueueService.NonExistentQueue" ||
|
|
31
|
-
err.code === "CredentialsProviderError");
|
|
41
|
+
return err.statusCode === 403 || CONNECTION_ERRORS.includes(err.code);
|
|
32
42
|
}
|
|
33
43
|
return false;
|
|
34
44
|
}
|
package/package.json
CHANGED
package/src/consumer.ts
CHANGED
|
@@ -251,6 +251,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
251
251
|
this.emitError(err);
|
|
252
252
|
if (isConnectionError(err)) {
|
|
253
253
|
logger.debug("authentication_error", {
|
|
254
|
+
code: err.code || "Unknown",
|
|
254
255
|
detail:
|
|
255
256
|
"There was an authentication error. Pausing before retrying.",
|
|
256
257
|
});
|
package/src/errors.ts
CHANGED
|
@@ -36,19 +36,28 @@ class StandardError extends Error {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* List of SQS error codes that are considered connection errors.
|
|
41
|
+
*/
|
|
42
|
+
const CONNECTION_ERRORS = [
|
|
43
|
+
"CredentialsError",
|
|
44
|
+
"UnknownEndpoint",
|
|
45
|
+
"AWS.SimpleQueueService.NonExistentQueue",
|
|
46
|
+
"CredentialsProviderError",
|
|
47
|
+
"InvalidAddress",
|
|
48
|
+
"InvalidSecurity",
|
|
49
|
+
"QueueDoesNotExist",
|
|
50
|
+
"RequestThrottled",
|
|
51
|
+
"OverLimit",
|
|
52
|
+
];
|
|
53
|
+
|
|
39
54
|
/**
|
|
40
55
|
* Checks if the error provided should be treated as a connection error.
|
|
41
56
|
* @param err The error that was received.
|
|
42
57
|
*/
|
|
43
58
|
function isConnectionError(err: Error): boolean {
|
|
44
59
|
if (err instanceof SQSError) {
|
|
45
|
-
return (
|
|
46
|
-
err.statusCode === 403 ||
|
|
47
|
-
err.code === "CredentialsError" ||
|
|
48
|
-
err.code === "UnknownEndpoint" ||
|
|
49
|
-
err.code === "AWS.SimpleQueueService.NonExistentQueue" ||
|
|
50
|
-
err.code === "CredentialsProviderError"
|
|
51
|
-
);
|
|
60
|
+
return err.statusCode === 403 || CONNECTION_ERRORS.includes(err.code);
|
|
52
61
|
}
|
|
53
62
|
return false;
|
|
54
63
|
}
|