sqs-consumer 14.2.3 → 14.2.4-canary.2
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/.releaserc.json +86 -0
- package/CHANGELOG.md +2 -20
- package/dist/cjs/consumer.js +6 -14
- package/dist/cjs/errors.d.ts +2 -2
- package/dist/cjs/types.d.ts +1 -1
- package/dist/cjs/validation.d.ts +2 -2
- package/dist/cjs/validation.js +2 -4
- package/dist/esm/consumer.js +6 -14
- package/dist/esm/errors.d.ts +2 -2
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/validation.d.ts +2 -2
- package/dist/esm/validation.js +2 -4
- package/package.json +40 -148
- package/src/consumer.ts +32 -83
- package/src/errors.ts +2 -2
- package/src/types.ts +2 -5
- package/src/validation.ts +7 -19
- package/vitest.config.ts +13 -0
package/.releaserc.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"branches": [
|
|
3
|
+
"main",
|
|
4
|
+
"*.x",
|
|
5
|
+
{
|
|
6
|
+
"name": "canary",
|
|
7
|
+
"prerelease": true
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"plugins": [
|
|
11
|
+
[
|
|
12
|
+
"@semantic-release/commit-analyzer",
|
|
13
|
+
{
|
|
14
|
+
"preset": "conventionalcommits",
|
|
15
|
+
"releaseRules": [
|
|
16
|
+
{
|
|
17
|
+
"type": "breaking",
|
|
18
|
+
"release": "major"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"type": "feat",
|
|
22
|
+
"release": "minor"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "chore",
|
|
26
|
+
"release": "patch"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "fix",
|
|
30
|
+
"release": "patch"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"type": "docs",
|
|
34
|
+
"release": "patch"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"type": "refactor",
|
|
38
|
+
"release": "patch"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "test",
|
|
42
|
+
"release": "patch"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
"@semantic-release/release-notes-generator",
|
|
49
|
+
{
|
|
50
|
+
"preset": "conventionalcommits",
|
|
51
|
+
"presetConfig": {
|
|
52
|
+
"types": [
|
|
53
|
+
{
|
|
54
|
+
"type": "feat",
|
|
55
|
+
"section": "Features"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "fix",
|
|
59
|
+
"section": "Bug Fixes"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"type": "chore",
|
|
63
|
+
"section": "Chores"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"type": "docs",
|
|
67
|
+
"section": "Documentation"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"type": "refactor",
|
|
71
|
+
"section": "Refactors"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"type": "test",
|
|
75
|
+
"section": "Tests"
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"@semantic-release/changelog",
|
|
82
|
+
"@semantic-release/github",
|
|
83
|
+
"@semantic-release/npm",
|
|
84
|
+
"@sebbo2002/semantic-release-jsr"
|
|
85
|
+
]
|
|
86
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
## [14.2.
|
|
1
|
+
## [14.2.4-canary.2](https://github.com/bbc/sqs-consumer/compare/v14.2.4-canary.1...v14.2.4-canary.2) (2026-03-20)
|
|
2
2
|
|
|
3
3
|
### Chores
|
|
4
4
|
|
|
5
|
-
*
|
|
6
|
-
* **deps-dev:** bump @semantic-release/github from 12.0.2 to 12.0.6 ([#720](https://github.com/bbc/sqs-consumer/issues/720)) ([a03c095](https://github.com/bbc/sqs-consumer/commit/a03c095dde365c018f7e5a9c3e48881a0e437a49))
|
|
7
|
-
* **deps-dev:** bump @semantic-release/npm from 13.1.3 to 13.1.4 ([#729](https://github.com/bbc/sqs-consumer/issues/729)) ([8deb591](https://github.com/bbc/sqs-consumer/commit/8deb5916ef0cbcaa779d5f15bc262f6e724d44c7))
|
|
8
|
-
* **deps-dev:** bump @types/node from 25.0.3 to 25.2.3 ([#723](https://github.com/bbc/sqs-consumer/issues/723)) ([3b7a194](https://github.com/bbc/sqs-consumer/commit/3b7a1944a27c325c5c70fa26f29d239838f14710))
|
|
9
|
-
* **deps-dev:** bump eslint from 9.39.2 to 9.39.3 ([#730](https://github.com/bbc/sqs-consumer/issues/730)) ([9fc0b8b](https://github.com/bbc/sqs-consumer/commit/9fc0b8b84803696e87774ab220c1dfa01af39de2))
|
|
10
|
-
* **deps-dev:** bump jsr from 0.13.5 to 0.14.3 ([#731](https://github.com/bbc/sqs-consumer/issues/731)) ([2880274](https://github.com/bbc/sqs-consumer/commit/28802745977d279111fdb486b1cafcb85bc5b5ef))
|
|
11
|
-
* **deps-dev:** bump prettier from 3.7.4 to 3.8.1 ([#719](https://github.com/bbc/sqs-consumer/issues/719)) ([f16caa0](https://github.com/bbc/sqs-consumer/commit/f16caa057c2761fc80cc39f938febf632d290541))
|
|
12
|
-
* **deps-dev:** bump semantic-release from 25.0.2 to 25.0.3 ([#732](https://github.com/bbc/sqs-consumer/issues/732)) ([26be35a](https://github.com/bbc/sqs-consumer/commit/26be35a0f57036ed023b35974f3b46a3d69b5939))
|
|
13
|
-
* **deps:** bump @aws-sdk/client-sqs from 3.970.0 to 3.989.0 ([#721](https://github.com/bbc/sqs-consumer/issues/721)) ([4c20ffb](https://github.com/bbc/sqs-consumer/commit/4c20ffb7bc241517e425f88ea3d8ba6e18a6fdce))
|
|
14
|
-
* **deps:** bump actions/dependency-review-action from 4.8.2 to 4.8.3 ([#725](https://github.com/bbc/sqs-consumer/issues/725)) ([20e7e73](https://github.com/bbc/sqs-consumer/commit/20e7e7340dfb4c765488b946e84da620cf045b9c))
|
|
15
|
-
* **deps:** bump actions/dependency-review-action from 4.8.3 to 4.9.0 ([#736](https://github.com/bbc/sqs-consumer/issues/736)) ([4ceae8a](https://github.com/bbc/sqs-consumer/commit/4ceae8a34ce171a3de0ab1f5383a41541021db80))
|
|
16
|
-
* **deps:** bump actions/upload-artifact from 6.0.0 to 7.0.0 ([#728](https://github.com/bbc/sqs-consumer/issues/728)) ([b0bd64b](https://github.com/bbc/sqs-consumer/commit/b0bd64b98e708d380d6c863e305f9d91c6bcef46))
|
|
17
|
-
* **deps:** bump dorny/test-reporter from 2.5.0 to 2.6.0 ([#735](https://github.com/bbc/sqs-consumer/issues/735)) ([8d56098](https://github.com/bbc/sqs-consumer/commit/8d5609894975eba6fd5feed18040d497f034aae4))
|
|
18
|
-
* **deps:** bump github/codeql-action from 4.32.3 to 4.32.4 ([#726](https://github.com/bbc/sqs-consumer/issues/726)) ([25ac8e4](https://github.com/bbc/sqs-consumer/commit/25ac8e4399b3e6a0ef16d40d106f68d9d0159fe1))
|
|
19
|
-
* **deps:** bump github/codeql-action from 4.32.4 to 4.32.5 ([#734](https://github.com/bbc/sqs-consumer/issues/734)) ([c69b87d](https://github.com/bbc/sqs-consumer/commit/c69b87de5b9c31a7716b5a0137fe49f9064e12b4))
|
|
20
|
-
* **deps:** bump tar in the npm_and_yarn group across 1 directory ([#727](https://github.com/bbc/sqs-consumer/issues/727)) ([774928b](https://github.com/bbc/sqs-consumer/commit/774928bb8b53849df16987ca8874dce5b7459adc))
|
|
21
|
-
* **deps:** bump the npm_and_yarn group across 1 directory with 4 updates ([#737](https://github.com/bbc/sqs-consumer/issues/737)) ([25a4582](https://github.com/bbc/sqs-consumer/commit/25a45825968cb82b427757f99a2c464444a121d7))
|
|
22
|
-
* **deps:** bump zgosalvez/github-actions-report-lcov ([#724](https://github.com/bbc/sqs-consumer/issues/724)) ([d28bf54](https://github.com/bbc/sqs-consumer/commit/d28bf540ee5de319e00fbc28e9a66c1cc0a63e57))
|
|
23
|
-
* **deps:** bump zgosalvez/github-actions-report-lcov ([#733](https://github.com/bbc/sqs-consumer/issues/733)) ([a62dabb](https://github.com/bbc/sqs-consumer/commit/a62dabb5528bd7d8a0d3c4853182833d589c33bf))
|
|
5
|
+
* modernising our toolchain ([#744](https://github.com/bbc/sqs-consumer/issues/744)) ([6c11aed](https://github.com/bbc/sqs-consumer/commit/6c11aede55e7ae369c37f39109473faed751ee40))
|
package/dist/cjs/consumer.js
CHANGED
|
@@ -26,16 +26,13 @@ class Consumer extends emitter_js_1.TypedEventEmitter {
|
|
|
26
26
|
this.handleMessageTimeout = options.handleMessageTimeout;
|
|
27
27
|
this.attributeNames = options.attributeNames || [];
|
|
28
28
|
this.messageAttributeNames = options.messageAttributeNames || [];
|
|
29
|
-
this.messageSystemAttributeNames =
|
|
30
|
-
options.messageSystemAttributeNames || [];
|
|
29
|
+
this.messageSystemAttributeNames = options.messageSystemAttributeNames || [];
|
|
31
30
|
this.batchSize = options.batchSize || 1;
|
|
32
31
|
this.visibilityTimeout = options.visibilityTimeout;
|
|
33
|
-
this.terminateVisibilityTimeout =
|
|
34
|
-
options.terminateVisibilityTimeout || false;
|
|
32
|
+
this.terminateVisibilityTimeout = options.terminateVisibilityTimeout || false;
|
|
35
33
|
this.heartbeatInterval = options.heartbeatInterval;
|
|
36
34
|
this.waitTimeSeconds = options.waitTimeSeconds ?? 20;
|
|
37
|
-
this.authenticationErrorTimeout =
|
|
38
|
-
options.authenticationErrorTimeout ?? 10000;
|
|
35
|
+
this.authenticationErrorTimeout = options.authenticationErrorTimeout ?? 10000;
|
|
39
36
|
this.pollingWaitTimeMs = options.pollingWaitTimeMs ?? 0;
|
|
40
37
|
this.pollingCompleteWaitTimeMs = options.pollingCompleteWaitTimeMs ?? 0;
|
|
41
38
|
this.shouldDeleteMessages = options.shouldDeleteMessages ?? true;
|
|
@@ -112,8 +109,7 @@ class Consumer extends emitter_js_1.TypedEventEmitter {
|
|
|
112
109
|
this.emit("stopped");
|
|
113
110
|
return;
|
|
114
111
|
}
|
|
115
|
-
const exceededTimeout = Date.now() - this.stopRequestedAtTimestamp >
|
|
116
|
-
this.pollingCompleteWaitTimeMs;
|
|
112
|
+
const exceededTimeout = Date.now() - this.stopRequestedAtTimestamp > this.pollingCompleteWaitTimeMs;
|
|
117
113
|
if (exceededTimeout) {
|
|
118
114
|
this.emit("waiting_for_polling_to_complete_timeout_exceeded");
|
|
119
115
|
this.emit("stopped");
|
|
@@ -272,9 +268,7 @@ class Consumer extends emitter_js_1.TypedEventEmitter {
|
|
|
272
268
|
await this.changeVisibilityTimeout(message, timeout);
|
|
273
269
|
}
|
|
274
270
|
else {
|
|
275
|
-
const timeout = this.terminateVisibilityTimeout === true
|
|
276
|
-
? 0
|
|
277
|
-
: this.terminateVisibilityTimeout;
|
|
271
|
+
const timeout = this.terminateVisibilityTimeout === true ? 0 : this.terminateVisibilityTimeout;
|
|
278
272
|
await this.changeVisibilityTimeout(message, timeout);
|
|
279
273
|
}
|
|
280
274
|
}
|
|
@@ -314,9 +308,7 @@ class Consumer extends emitter_js_1.TypedEventEmitter {
|
|
|
314
308
|
await this.changeVisibilityTimeoutBatch(messages, timeout);
|
|
315
309
|
}
|
|
316
310
|
else {
|
|
317
|
-
const timeout = this.terminateVisibilityTimeout === true
|
|
318
|
-
? 0
|
|
319
|
-
: this.terminateVisibilityTimeout;
|
|
311
|
+
const timeout = this.terminateVisibilityTimeout === true ? 0 : this.terminateVisibilityTimeout;
|
|
320
312
|
await this.changeVisibilityTimeoutBatch(messages, timeout);
|
|
321
313
|
}
|
|
322
314
|
}
|
package/dist/cjs/errors.d.ts
CHANGED
package/dist/cjs/types.d.ts
CHANGED
package/dist/cjs/validation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReceiveMessageCommandOutput } from "@aws-sdk/client-sqs";
|
|
2
|
-
import { ConsumerOptions } from "./types.js";
|
|
1
|
+
import type { ReceiveMessageCommandOutput } from "@aws-sdk/client-sqs";
|
|
2
|
+
import type { ConsumerOptions } from "./types.js";
|
|
3
3
|
declare function validateOption(option: string, value: any, allOptions: {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
}, strict?: boolean): void;
|
package/dist/cjs/validation.js
CHANGED
|
@@ -16,14 +16,12 @@ function validateOption(option, value, allOptions, strict) {
|
|
|
16
16
|
}
|
|
17
17
|
break;
|
|
18
18
|
case "heartbeatInterval":
|
|
19
|
-
if (!allOptions.visibilityTimeout ||
|
|
20
|
-
value >= allOptions.visibilityTimeout) {
|
|
19
|
+
if (!allOptions.visibilityTimeout || value >= allOptions.visibilityTimeout) {
|
|
21
20
|
throw new Error("heartbeatInterval must be less than visibilityTimeout.");
|
|
22
21
|
}
|
|
23
22
|
break;
|
|
24
23
|
case "visibilityTimeout":
|
|
25
|
-
if (allOptions.heartbeatInterval &&
|
|
26
|
-
value <= allOptions.heartbeatInterval) {
|
|
24
|
+
if (allOptions.heartbeatInterval && value <= allOptions.heartbeatInterval) {
|
|
27
25
|
throw new Error("heartbeatInterval must be less than visibilityTimeout.");
|
|
28
26
|
}
|
|
29
27
|
break;
|
package/dist/esm/consumer.js
CHANGED
|
@@ -23,16 +23,13 @@ export class Consumer extends TypedEventEmitter {
|
|
|
23
23
|
this.handleMessageTimeout = options.handleMessageTimeout;
|
|
24
24
|
this.attributeNames = options.attributeNames || [];
|
|
25
25
|
this.messageAttributeNames = options.messageAttributeNames || [];
|
|
26
|
-
this.messageSystemAttributeNames =
|
|
27
|
-
options.messageSystemAttributeNames || [];
|
|
26
|
+
this.messageSystemAttributeNames = options.messageSystemAttributeNames || [];
|
|
28
27
|
this.batchSize = options.batchSize || 1;
|
|
29
28
|
this.visibilityTimeout = options.visibilityTimeout;
|
|
30
|
-
this.terminateVisibilityTimeout =
|
|
31
|
-
options.terminateVisibilityTimeout || false;
|
|
29
|
+
this.terminateVisibilityTimeout = options.terminateVisibilityTimeout || false;
|
|
32
30
|
this.heartbeatInterval = options.heartbeatInterval;
|
|
33
31
|
this.waitTimeSeconds = options.waitTimeSeconds ?? 20;
|
|
34
|
-
this.authenticationErrorTimeout =
|
|
35
|
-
options.authenticationErrorTimeout ?? 10000;
|
|
32
|
+
this.authenticationErrorTimeout = options.authenticationErrorTimeout ?? 10000;
|
|
36
33
|
this.pollingWaitTimeMs = options.pollingWaitTimeMs ?? 0;
|
|
37
34
|
this.pollingCompleteWaitTimeMs = options.pollingCompleteWaitTimeMs ?? 0;
|
|
38
35
|
this.shouldDeleteMessages = options.shouldDeleteMessages ?? true;
|
|
@@ -109,8 +106,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
109
106
|
this.emit("stopped");
|
|
110
107
|
return;
|
|
111
108
|
}
|
|
112
|
-
const exceededTimeout = Date.now() - this.stopRequestedAtTimestamp >
|
|
113
|
-
this.pollingCompleteWaitTimeMs;
|
|
109
|
+
const exceededTimeout = Date.now() - this.stopRequestedAtTimestamp > this.pollingCompleteWaitTimeMs;
|
|
114
110
|
if (exceededTimeout) {
|
|
115
111
|
this.emit("waiting_for_polling_to_complete_timeout_exceeded");
|
|
116
112
|
this.emit("stopped");
|
|
@@ -269,9 +265,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
269
265
|
await this.changeVisibilityTimeout(message, timeout);
|
|
270
266
|
}
|
|
271
267
|
else {
|
|
272
|
-
const timeout = this.terminateVisibilityTimeout === true
|
|
273
|
-
? 0
|
|
274
|
-
: this.terminateVisibilityTimeout;
|
|
268
|
+
const timeout = this.terminateVisibilityTimeout === true ? 0 : this.terminateVisibilityTimeout;
|
|
275
269
|
await this.changeVisibilityTimeout(message, timeout);
|
|
276
270
|
}
|
|
277
271
|
}
|
|
@@ -311,9 +305,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
311
305
|
await this.changeVisibilityTimeoutBatch(messages, timeout);
|
|
312
306
|
}
|
|
313
307
|
else {
|
|
314
|
-
const timeout = this.terminateVisibilityTimeout === true
|
|
315
|
-
? 0
|
|
316
|
-
: this.terminateVisibilityTimeout;
|
|
308
|
+
const timeout = this.terminateVisibilityTimeout === true ? 0 : this.terminateVisibilityTimeout;
|
|
317
309
|
await this.changeVisibilityTimeoutBatch(messages, timeout);
|
|
318
310
|
}
|
|
319
311
|
}
|
package/dist/esm/errors.d.ts
CHANGED
package/dist/esm/types.d.ts
CHANGED
package/dist/esm/validation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReceiveMessageCommandOutput } from "@aws-sdk/client-sqs";
|
|
2
|
-
import { ConsumerOptions } from "./types.js";
|
|
1
|
+
import type { ReceiveMessageCommandOutput } from "@aws-sdk/client-sqs";
|
|
2
|
+
import type { ConsumerOptions } from "./types.js";
|
|
3
3
|
declare function validateOption(option: string, value: any, allOptions: {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
}, strict?: boolean): void;
|
package/dist/esm/validation.js
CHANGED
|
@@ -11,14 +11,12 @@ function validateOption(option, value, allOptions, strict) {
|
|
|
11
11
|
}
|
|
12
12
|
break;
|
|
13
13
|
case "heartbeatInterval":
|
|
14
|
-
if (!allOptions.visibilityTimeout ||
|
|
15
|
-
value >= allOptions.visibilityTimeout) {
|
|
14
|
+
if (!allOptions.visibilityTimeout || value >= allOptions.visibilityTimeout) {
|
|
16
15
|
throw new Error("heartbeatInterval must be less than visibilityTimeout.");
|
|
17
16
|
}
|
|
18
17
|
break;
|
|
19
18
|
case "visibilityTimeout":
|
|
20
|
-
if (allOptions.heartbeatInterval &&
|
|
21
|
-
value <= allOptions.heartbeatInterval) {
|
|
19
|
+
if (allOptions.heartbeatInterval && value <= allOptions.heartbeatInterval) {
|
|
22
20
|
throw new Error("heartbeatInterval must be less than visibilityTimeout.");
|
|
23
21
|
}
|
|
24
22
|
break;
|
package/package.json
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sqs-consumer",
|
|
3
|
-
"version": "14.2.
|
|
3
|
+
"version": "14.2.4-canary.2",
|
|
4
4
|
"description": "Build SQS-based Node applications without the boilerplate",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"consumer",
|
|
7
|
+
"queue",
|
|
8
|
+
"sqs"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://bbc.github.io/sqs-consumer/",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/bbc/sqs-consumer/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/bbc/sqs-consumer.git"
|
|
18
|
+
},
|
|
5
19
|
"type": "module",
|
|
6
20
|
"main": "dist/cjs/index.js",
|
|
7
21
|
"types": "dist/cjs/index.d.ts",
|
|
@@ -17,8 +31,8 @@
|
|
|
17
31
|
}
|
|
18
32
|
}
|
|
19
33
|
},
|
|
20
|
-
"
|
|
21
|
-
"
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"provenance": true
|
|
22
36
|
},
|
|
23
37
|
"scripts": {
|
|
24
38
|
"clean": "rm -fr dist/*",
|
|
@@ -28,126 +42,25 @@
|
|
|
28
42
|
"watch": "tsc --watch",
|
|
29
43
|
"prepublishOnly": "npm run build",
|
|
30
44
|
"release": "semantic-release",
|
|
31
|
-
"test:unit": "
|
|
32
|
-
"test:unit:report": "
|
|
45
|
+
"test:unit": "vitest run --config ./vitest.config.ts",
|
|
46
|
+
"test:unit:report": "vitest run --config ./vitest.config.ts --reporter=junit --outputFile=test/reports/test-results.xml",
|
|
33
47
|
"pretest:integration:init": "npm run build",
|
|
34
|
-
"test:integration:init": "
|
|
48
|
+
"test:integration:init": "bash ./test/scripts/initIntTests.sh",
|
|
35
49
|
"test:integration": "npm run test:integration:init && cucumber-js --config ./test/config/cucumber.mjs",
|
|
36
50
|
"test": "npm run test:unit:report && npm run test:integration",
|
|
37
|
-
"coverage": "
|
|
38
|
-
"lcov": "
|
|
39
|
-
"
|
|
40
|
-
"lint
|
|
41
|
-
"
|
|
42
|
-
"format
|
|
43
|
-
"
|
|
51
|
+
"coverage": "vitest run --config ./vitest.config.ts --coverage --coverage.reporter=html --coverage.reporter=json-summary",
|
|
52
|
+
"lcov": "vitest run --config ./vitest.config.ts --coverage --coverage.reporter=lcov",
|
|
53
|
+
"typecheck": "tsc --noEmit",
|
|
54
|
+
"lint": "oxlint",
|
|
55
|
+
"lint:fix": "oxlint --fix",
|
|
56
|
+
"format": "oxfmt",
|
|
57
|
+
"format:check": "oxfmt --check",
|
|
58
|
+
"check": "npm run lint && npm run format:check && npm run typecheck && npm run test",
|
|
44
59
|
"generate-docs": "typedoc"
|
|
45
60
|
},
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
},
|
|
50
|
-
"bugs": {
|
|
51
|
-
"url": "https://github.com/bbc/sqs-consumer/issues"
|
|
52
|
-
},
|
|
53
|
-
"homepage": "https://bbc.github.io/sqs-consumer/",
|
|
54
|
-
"keywords": [
|
|
55
|
-
"sqs",
|
|
56
|
-
"queue",
|
|
57
|
-
"consumer"
|
|
58
|
-
],
|
|
59
|
-
"license": "Apache-2.0",
|
|
60
|
-
"publishConfig": {
|
|
61
|
-
"provenance": true
|
|
62
|
-
},
|
|
63
|
-
"release": {
|
|
64
|
-
"branches": [
|
|
65
|
-
"main",
|
|
66
|
-
"*.x",
|
|
67
|
-
{
|
|
68
|
-
"name": "canary",
|
|
69
|
-
"prerelease": true
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
"plugins": [
|
|
73
|
-
[
|
|
74
|
-
"@semantic-release/commit-analyzer",
|
|
75
|
-
{
|
|
76
|
-
"preset": "conventionalcommits",
|
|
77
|
-
"releaseRules": [
|
|
78
|
-
{
|
|
79
|
-
"type": "breaking",
|
|
80
|
-
"release": "major"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"type": "feat",
|
|
84
|
-
"release": "minor"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"type": "chore",
|
|
88
|
-
"release": "patch"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"type": "fix",
|
|
92
|
-
"release": "patch"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"type": "docs",
|
|
96
|
-
"release": "patch"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"type": "refactor",
|
|
100
|
-
"release": "patch"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"type": "test",
|
|
104
|
-
"release": "patch"
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
],
|
|
109
|
-
[
|
|
110
|
-
"@semantic-release/release-notes-generator",
|
|
111
|
-
{
|
|
112
|
-
"preset": "conventionalcommits",
|
|
113
|
-
"presetConfig": {
|
|
114
|
-
"types": [
|
|
115
|
-
{
|
|
116
|
-
"type": "feat",
|
|
117
|
-
"section": "Features"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"type": "fix",
|
|
121
|
-
"section": "Bug Fixes"
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"type": "chore",
|
|
125
|
-
"section": "Chores"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"type": "docs",
|
|
129
|
-
"section": "Documentation"
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"type": "refactor",
|
|
133
|
-
"section": "Refactors"
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
"type": "test",
|
|
137
|
-
"section": "Tests"
|
|
138
|
-
}
|
|
139
|
-
]
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
],
|
|
143
|
-
"@semantic-release/changelog",
|
|
144
|
-
"@semantic-release/github",
|
|
145
|
-
"@semantic-release/npm",
|
|
146
|
-
"@sebbo2002/semantic-release-jsr"
|
|
147
|
-
]
|
|
148
|
-
},
|
|
149
|
-
"overrides": {
|
|
150
|
-
"cross-spawn": "^7.0.3"
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@aws-sdk/client-sqs": "^3.989.0",
|
|
63
|
+
"debug": "^4.4.3"
|
|
151
64
|
},
|
|
152
65
|
"devDependencies": {
|
|
153
66
|
"@cucumber/cucumber": "^12.6.0",
|
|
@@ -159,51 +72,30 @@
|
|
|
159
72
|
"@semantic-release/npm": "^13.1.4",
|
|
160
73
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
161
74
|
"@types/chai": "^5.2.2",
|
|
162
|
-
"@types/mocha": "^10.0.10",
|
|
163
75
|
"@types/node": "^25.2.3",
|
|
164
76
|
"@types/sinon": "^17.0.4",
|
|
165
|
-
"@
|
|
166
|
-
"@typescript-eslint/parser": "^8.50.1",
|
|
167
|
-
"c8": "^10.1.3",
|
|
77
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
168
78
|
"chai": "^6.2.2",
|
|
169
79
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
170
|
-
"eslint": "^9.39.3",
|
|
171
|
-
"eslint-config-eslint": "^13.0.0",
|
|
172
80
|
"jsr": "^0.14.3",
|
|
173
|
-
"
|
|
81
|
+
"oxfmt": "^0.41.0",
|
|
82
|
+
"oxlint": "^1.56.0",
|
|
174
83
|
"p-event": "^7.0.2",
|
|
175
|
-
"prettier": "^3.8.1",
|
|
176
84
|
"semantic-release": "^25.0.3",
|
|
177
85
|
"sinon": "^21.0.0",
|
|
178
86
|
"sqs-producer": "^8.0.2",
|
|
179
87
|
"ts-node": "^10.9.2",
|
|
180
88
|
"typedoc": "^0.28.16",
|
|
181
|
-
"typescript": "^5.9.3"
|
|
182
|
-
|
|
183
|
-
"dependencies": {
|
|
184
|
-
"@aws-sdk/client-sqs": "^3.989.0",
|
|
185
|
-
"debug": "^4.4.3"
|
|
89
|
+
"typescript": "^5.9.3",
|
|
90
|
+
"vitest": "^3.2.4"
|
|
186
91
|
},
|
|
187
92
|
"peerDependencies": {
|
|
188
93
|
"@aws-sdk/client-sqs": "^3.989.0"
|
|
189
94
|
},
|
|
190
|
-
"
|
|
191
|
-
"
|
|
192
|
-
"ts"
|
|
193
|
-
],
|
|
194
|
-
"spec": "test/tests/**/**/*.test.ts",
|
|
195
|
-
"node-option": [
|
|
196
|
-
"loader=ts-node/esm"
|
|
197
|
-
]
|
|
95
|
+
"overrides": {
|
|
96
|
+
"cross-spawn": "^7.0.3"
|
|
198
97
|
},
|
|
199
|
-
"
|
|
200
|
-
"
|
|
201
|
-
"src/**/*.ts"
|
|
202
|
-
],
|
|
203
|
-
"extension": [
|
|
204
|
-
".ts"
|
|
205
|
-
],
|
|
206
|
-
"sourceMap": true,
|
|
207
|
-
"instrument": true
|
|
98
|
+
"engines": {
|
|
99
|
+
"node": ">=20.0.0"
|
|
208
100
|
}
|
|
209
101
|
}
|
package/src/consumer.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SQSClient,
|
|
3
|
-
Message,
|
|
4
3
|
ChangeMessageVisibilityCommand,
|
|
4
|
+
ChangeMessageVisibilityBatchCommand,
|
|
5
|
+
DeleteMessageCommand,
|
|
6
|
+
DeleteMessageBatchCommand,
|
|
7
|
+
ReceiveMessageCommand,
|
|
8
|
+
} from "@aws-sdk/client-sqs";
|
|
9
|
+
import type {
|
|
10
|
+
Message,
|
|
5
11
|
ChangeMessageVisibilityCommandInput,
|
|
6
12
|
ChangeMessageVisibilityCommandOutput,
|
|
7
|
-
ChangeMessageVisibilityBatchCommand,
|
|
8
13
|
ChangeMessageVisibilityBatchCommandInput,
|
|
9
14
|
ChangeMessageVisibilityBatchCommandOutput,
|
|
10
|
-
DeleteMessageCommand,
|
|
11
15
|
DeleteMessageCommandInput,
|
|
12
|
-
DeleteMessageBatchCommand,
|
|
13
16
|
DeleteMessageBatchCommandInput,
|
|
14
|
-
ReceiveMessageCommand,
|
|
15
17
|
ReceiveMessageCommandInput,
|
|
16
18
|
ReceiveMessageCommandOutput,
|
|
17
19
|
QueueAttributeName,
|
|
18
20
|
MessageSystemAttributeName,
|
|
19
21
|
} from "@aws-sdk/client-sqs";
|
|
20
22
|
|
|
21
|
-
import type {
|
|
22
|
-
ConsumerOptions,
|
|
23
|
-
StopOptions,
|
|
24
|
-
UpdatableOptions,
|
|
25
|
-
} from "./types.js";
|
|
23
|
+
import type { ConsumerOptions, StopOptions, UpdatableOptions } from "./types.js";
|
|
26
24
|
import { TypedEventEmitter } from "./emitter.js";
|
|
27
25
|
import {
|
|
28
26
|
SQSError,
|
|
@@ -45,9 +43,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
45
43
|
private isFifoQueue: boolean;
|
|
46
44
|
private suppressFifoWarning: boolean;
|
|
47
45
|
private handleMessage: (message: Message) => Promise<Message | undefined>;
|
|
48
|
-
private handleMessageBatch: (
|
|
49
|
-
messages: Message[],
|
|
50
|
-
) => Promise<Message[] | undefined>;
|
|
46
|
+
private handleMessageBatch: (messages: Message[]) => Promise<Message[] | undefined>;
|
|
51
47
|
private preReceiveMessageCallback?: () => Promise<void>;
|
|
52
48
|
private postReceiveMessageCallback?: () => Promise<void>;
|
|
53
49
|
private sqs: SQSClient;
|
|
@@ -59,10 +55,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
59
55
|
private alwaysAcknowledge: boolean;
|
|
60
56
|
private batchSize: number;
|
|
61
57
|
private visibilityTimeout: number;
|
|
62
|
-
private terminateVisibilityTimeout:
|
|
63
|
-
| boolean
|
|
64
|
-
| number
|
|
65
|
-
| ((message: Message[]) => number);
|
|
58
|
+
private terminateVisibilityTimeout: boolean | number | ((message: Message[]) => number);
|
|
66
59
|
private waitTimeSeconds: number;
|
|
67
60
|
private authenticationErrorTimeout: number;
|
|
68
61
|
private pollingWaitTimeMs: number;
|
|
@@ -87,16 +80,13 @@ export class Consumer extends TypedEventEmitter {
|
|
|
87
80
|
this.handleMessageTimeout = options.handleMessageTimeout;
|
|
88
81
|
this.attributeNames = options.attributeNames || [];
|
|
89
82
|
this.messageAttributeNames = options.messageAttributeNames || [];
|
|
90
|
-
this.messageSystemAttributeNames =
|
|
91
|
-
options.messageSystemAttributeNames || [];
|
|
83
|
+
this.messageSystemAttributeNames = options.messageSystemAttributeNames || [];
|
|
92
84
|
this.batchSize = options.batchSize || 1;
|
|
93
85
|
this.visibilityTimeout = options.visibilityTimeout;
|
|
94
|
-
this.terminateVisibilityTimeout =
|
|
95
|
-
options.terminateVisibilityTimeout || false;
|
|
86
|
+
this.terminateVisibilityTimeout = options.terminateVisibilityTimeout || false;
|
|
96
87
|
this.heartbeatInterval = options.heartbeatInterval;
|
|
97
88
|
this.waitTimeSeconds = options.waitTimeSeconds ?? 20;
|
|
98
|
-
this.authenticationErrorTimeout =
|
|
99
|
-
options.authenticationErrorTimeout ?? 10000;
|
|
89
|
+
this.authenticationErrorTimeout = options.authenticationErrorTimeout ?? 10000;
|
|
100
90
|
this.pollingWaitTimeMs = options.pollingWaitTimeMs ?? 0;
|
|
101
91
|
this.pollingCompleteWaitTimeMs = options.pollingCompleteWaitTimeMs ?? 0;
|
|
102
92
|
this.shouldDeleteMessages = options.shouldDeleteMessages ?? true;
|
|
@@ -186,8 +176,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
186
176
|
}
|
|
187
177
|
|
|
188
178
|
const exceededTimeout: boolean =
|
|
189
|
-
Date.now() - this.stopRequestedAtTimestamp >
|
|
190
|
-
this.pollingCompleteWaitTimeMs;
|
|
179
|
+
Date.now() - this.stopRequestedAtTimestamp > this.pollingCompleteWaitTimeMs;
|
|
191
180
|
if (exceededTimeout) {
|
|
192
181
|
this.emit("waiting_for_polling_to_complete_timeout_exceeded");
|
|
193
182
|
this.emit("stopped");
|
|
@@ -217,10 +206,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
217
206
|
* @param option The option to validate and then update
|
|
218
207
|
* @param value The value to set the provided option to
|
|
219
208
|
*/
|
|
220
|
-
public updateOption(
|
|
221
|
-
option: UpdatableOptions,
|
|
222
|
-
value: ConsumerOptions[UpdatableOptions],
|
|
223
|
-
): void {
|
|
209
|
+
public updateOption(option: UpdatableOptions, value: ConsumerOptions[UpdatableOptions]): void {
|
|
224
210
|
validateOption(option, value, this, true);
|
|
225
211
|
|
|
226
212
|
this[option] = value;
|
|
@@ -251,8 +237,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
251
237
|
private poll(): void {
|
|
252
238
|
if (this.stopped) {
|
|
253
239
|
logger.debug("cancelling_poll", {
|
|
254
|
-
detail:
|
|
255
|
-
"Poll was called while consumer was stopped, cancelling poll...",
|
|
240
|
+
detail: "Poll was called while consumer was stopped, cancelling poll...",
|
|
256
241
|
});
|
|
257
242
|
return;
|
|
258
243
|
}
|
|
@@ -271,16 +256,13 @@ export class Consumer extends TypedEventEmitter {
|
|
|
271
256
|
WaitTimeSeconds: this.waitTimeSeconds,
|
|
272
257
|
VisibilityTimeout: this.visibilityTimeout,
|
|
273
258
|
})
|
|
274
|
-
.then((output: ReceiveMessageCommandOutput) =>
|
|
275
|
-
this.handleSqsResponse(output),
|
|
276
|
-
)
|
|
259
|
+
.then((output: ReceiveMessageCommandOutput) => this.handleSqsResponse(output))
|
|
277
260
|
.catch((err): void => {
|
|
278
261
|
this.emitError(err);
|
|
279
262
|
if (isConnectionError(err)) {
|
|
280
263
|
logger.debug("authentication_error", {
|
|
281
264
|
code: err.code || "Unknown",
|
|
282
|
-
detail:
|
|
283
|
-
"There was an authentication error. Pausing before retrying.",
|
|
265
|
+
detail: "There was an authentication error. Pausing before retrying.",
|
|
284
266
|
});
|
|
285
267
|
currentPollingTimeout = this.authenticationErrorTimeout;
|
|
286
268
|
}
|
|
@@ -290,10 +272,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
290
272
|
if (this.pollingTimeoutId) {
|
|
291
273
|
clearTimeout(this.pollingTimeoutId);
|
|
292
274
|
}
|
|
293
|
-
this.pollingTimeoutId = setTimeout(
|
|
294
|
-
() => this.poll(),
|
|
295
|
-
currentPollingTimeout,
|
|
296
|
-
);
|
|
275
|
+
this.pollingTimeoutId = setTimeout(() => this.poll(), currentPollingTimeout);
|
|
297
276
|
})
|
|
298
277
|
.catch((err): void => {
|
|
299
278
|
this.emitError(err);
|
|
@@ -338,17 +317,13 @@ export class Consumer extends TypedEventEmitter {
|
|
|
338
317
|
* the message handler.
|
|
339
318
|
* @param response The output from AWS SQS
|
|
340
319
|
*/
|
|
341
|
-
private async handleSqsResponse(
|
|
342
|
-
response: ReceiveMessageCommandOutput,
|
|
343
|
-
): Promise<void> {
|
|
320
|
+
private async handleSqsResponse(response: ReceiveMessageCommandOutput): Promise<void> {
|
|
344
321
|
if (hasMessages(response)) {
|
|
345
322
|
if (this.handleMessageBatch) {
|
|
346
323
|
await this.processMessageBatch(response.Messages);
|
|
347
324
|
} else {
|
|
348
325
|
await Promise.all(
|
|
349
|
-
response.Messages.map((message: Message) =>
|
|
350
|
-
this.processMessage(message),
|
|
351
|
-
),
|
|
326
|
+
response.Messages.map((message: Message) => this.processMessage(message)),
|
|
352
327
|
);
|
|
353
328
|
}
|
|
354
329
|
|
|
@@ -389,9 +364,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
389
364
|
await this.changeVisibilityTimeout(message, timeout);
|
|
390
365
|
} else {
|
|
391
366
|
const timeout =
|
|
392
|
-
this.terminateVisibilityTimeout === true
|
|
393
|
-
? 0
|
|
394
|
-
: this.terminateVisibilityTimeout;
|
|
367
|
+
this.terminateVisibilityTimeout === true ? 0 : this.terminateVisibilityTimeout;
|
|
395
368
|
await this.changeVisibilityTimeout(message, timeout);
|
|
396
369
|
}
|
|
397
370
|
}
|
|
@@ -436,9 +409,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
436
409
|
await this.changeVisibilityTimeoutBatch(messages, timeout);
|
|
437
410
|
} else {
|
|
438
411
|
const timeout =
|
|
439
|
-
this.terminateVisibilityTimeout === true
|
|
440
|
-
? 0
|
|
441
|
-
: this.terminateVisibilityTimeout;
|
|
412
|
+
this.terminateVisibilityTimeout === true ? 0 : this.terminateVisibilityTimeout;
|
|
442
413
|
await this.changeVisibilityTimeoutBatch(messages, timeout);
|
|
443
414
|
}
|
|
444
415
|
}
|
|
@@ -451,16 +422,10 @@ export class Consumer extends TypedEventEmitter {
|
|
|
451
422
|
* Trigger a function on a set interval
|
|
452
423
|
* @param heartbeatFn The function that should be triggered
|
|
453
424
|
*/
|
|
454
|
-
private startHeartbeat(
|
|
455
|
-
message?: Message,
|
|
456
|
-
messages?: Message[],
|
|
457
|
-
): NodeJS.Timeout {
|
|
425
|
+
private startHeartbeat(message?: Message, messages?: Message[]): NodeJS.Timeout {
|
|
458
426
|
return setInterval(() => {
|
|
459
427
|
if (this.handleMessageBatch) {
|
|
460
|
-
return this.changeVisibilityTimeoutBatch(
|
|
461
|
-
messages,
|
|
462
|
-
this.visibilityTimeout,
|
|
463
|
-
);
|
|
428
|
+
return this.changeVisibilityTimeoutBatch(messages, this.visibilityTimeout);
|
|
464
429
|
}
|
|
465
430
|
|
|
466
431
|
return this.changeVisibilityTimeout(message, this.visibilityTimeout);
|
|
@@ -482,10 +447,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
482
447
|
ReceiptHandle: message.ReceiptHandle,
|
|
483
448
|
VisibilityTimeout: timeout,
|
|
484
449
|
};
|
|
485
|
-
return await this.sqs.send(
|
|
486
|
-
new ChangeMessageVisibilityCommand(input),
|
|
487
|
-
this.sqsSendOptions,
|
|
488
|
-
);
|
|
450
|
+
return await this.sqs.send(new ChangeMessageVisibilityCommand(input), this.sqsSendOptions);
|
|
489
451
|
} catch (err) {
|
|
490
452
|
this.emit(
|
|
491
453
|
"error",
|
|
@@ -593,11 +555,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
593
555
|
);
|
|
594
556
|
}
|
|
595
557
|
if (err instanceof Error) {
|
|
596
|
-
throw toStandardError(
|
|
597
|
-
err,
|
|
598
|
-
`Unexpected message handler failure: ${err.message}`,
|
|
599
|
-
message,
|
|
600
|
-
);
|
|
558
|
+
throw toStandardError(err, `Unexpected message handler failure: ${err.message}`, message);
|
|
601
559
|
}
|
|
602
560
|
throw err;
|
|
603
561
|
} finally {
|
|
@@ -613,8 +571,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
613
571
|
*/
|
|
614
572
|
private async executeBatchHandler(messages: Message[]): Promise<Message[]> {
|
|
615
573
|
try {
|
|
616
|
-
const result: Message[] | undefined | null =
|
|
617
|
-
await this.handleMessageBatch(messages);
|
|
574
|
+
const result: Message[] | undefined | null = await this.handleMessageBatch(messages);
|
|
618
575
|
|
|
619
576
|
if (this.alwaysAcknowledge) {
|
|
620
577
|
return messages;
|
|
@@ -661,8 +618,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
661
618
|
private async deleteMessage(message: Message): Promise<void> {
|
|
662
619
|
if (!this.shouldDeleteMessages) {
|
|
663
620
|
logger.debug("skipping_delete", {
|
|
664
|
-
detail:
|
|
665
|
-
"Skipping message delete since shouldDeleteMessages is set to false",
|
|
621
|
+
detail: "Skipping message delete since shouldDeleteMessages is set to false",
|
|
666
622
|
});
|
|
667
623
|
return;
|
|
668
624
|
}
|
|
@@ -674,10 +630,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
674
630
|
};
|
|
675
631
|
|
|
676
632
|
try {
|
|
677
|
-
await this.sqs.send(
|
|
678
|
-
new DeleteMessageCommand(deleteParams),
|
|
679
|
-
this.sqsSendOptions,
|
|
680
|
-
);
|
|
633
|
+
await this.sqs.send(new DeleteMessageCommand(deleteParams), this.sqsSendOptions);
|
|
681
634
|
} catch (err) {
|
|
682
635
|
throw toSQSError(
|
|
683
636
|
err,
|
|
@@ -696,8 +649,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
696
649
|
private async deleteMessageBatch(messages: Message[]): Promise<void> {
|
|
697
650
|
if (!this.shouldDeleteMessages) {
|
|
698
651
|
logger.debug("skipping_delete", {
|
|
699
|
-
detail:
|
|
700
|
-
"Skipping message delete since shouldDeleteMessages is set to false",
|
|
652
|
+
detail: "Skipping message delete since shouldDeleteMessages is set to false",
|
|
701
653
|
});
|
|
702
654
|
return;
|
|
703
655
|
}
|
|
@@ -714,10 +666,7 @@ export class Consumer extends TypedEventEmitter {
|
|
|
714
666
|
};
|
|
715
667
|
|
|
716
668
|
try {
|
|
717
|
-
await this.sqs.send(
|
|
718
|
-
new DeleteMessageBatchCommand(deleteParams),
|
|
719
|
-
this.sqsSendOptions,
|
|
720
|
-
);
|
|
669
|
+
await this.sqs.send(new DeleteMessageBatchCommand(deleteParams), this.sqsSendOptions);
|
|
721
670
|
} catch (err) {
|
|
722
671
|
throw toSQSError(
|
|
723
672
|
err,
|
package/src/errors.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
SQSClient,
|
|
3
3
|
Message,
|
|
4
4
|
QueueAttributeName,
|
|
@@ -72,10 +72,7 @@ export interface ConsumerOptions {
|
|
|
72
72
|
* a number and it will use that as the value for the timeout.
|
|
73
73
|
* @defaultvalue `false`
|
|
74
74
|
*/
|
|
75
|
-
terminateVisibilityTimeout?:
|
|
76
|
-
| boolean
|
|
77
|
-
| number
|
|
78
|
-
| ((messages: Message[]) => number);
|
|
75
|
+
terminateVisibilityTimeout?: boolean | number | ((messages: Message[]) => number);
|
|
79
76
|
/**
|
|
80
77
|
* The interval (in seconds) between requests to extend the message visibility timeout.
|
|
81
78
|
*
|
package/src/validation.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReceiveMessageCommandOutput } from "@aws-sdk/client-sqs";
|
|
1
|
+
import type { ReceiveMessageCommandOutput } from "@aws-sdk/client-sqs";
|
|
2
2
|
|
|
3
|
-
import { ConsumerOptions } from "./types.js";
|
|
3
|
+
import type { ConsumerOptions } from "./types.js";
|
|
4
4
|
|
|
5
5
|
const requiredOptions = [
|
|
6
6
|
"queueUrl",
|
|
@@ -21,23 +21,13 @@ function validateOption(
|
|
|
21
21
|
}
|
|
22
22
|
break;
|
|
23
23
|
case "heartbeatInterval":
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
value >= allOptions.visibilityTimeout
|
|
27
|
-
) {
|
|
28
|
-
throw new Error(
|
|
29
|
-
"heartbeatInterval must be less than visibilityTimeout.",
|
|
30
|
-
);
|
|
24
|
+
if (!allOptions.visibilityTimeout || value >= allOptions.visibilityTimeout) {
|
|
25
|
+
throw new Error("heartbeatInterval must be less than visibilityTimeout.");
|
|
31
26
|
}
|
|
32
27
|
break;
|
|
33
28
|
case "visibilityTimeout":
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
value <= allOptions.heartbeatInterval
|
|
37
|
-
) {
|
|
38
|
-
throw new Error(
|
|
39
|
-
"heartbeatInterval must be less than visibilityTimeout.",
|
|
40
|
-
);
|
|
29
|
+
if (allOptions.heartbeatInterval && value <= allOptions.heartbeatInterval) {
|
|
30
|
+
throw new Error("heartbeatInterval must be less than visibilityTimeout.");
|
|
41
31
|
}
|
|
42
32
|
break;
|
|
43
33
|
case "waitTimeSeconds":
|
|
@@ -66,9 +56,7 @@ function assertOptions(options: ConsumerOptions): void {
|
|
|
66
56
|
requiredOptions.forEach((option) => {
|
|
67
57
|
const possibilities = option.split("|");
|
|
68
58
|
if (!possibilities.find((p) => options[p])) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
`Missing SQS consumer option [ ${possibilities.join(" or ")} ].`,
|
|
71
|
-
);
|
|
59
|
+
throw new Error(`Missing SQS consumer option [ ${possibilities.join(" or ")} ].`);
|
|
72
60
|
}
|
|
73
61
|
});
|
|
74
62
|
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
environment: "node",
|
|
6
|
+
include: ["test/tests/**/*.test.ts"],
|
|
7
|
+
dangerouslyIgnoreUnhandledErrors: true,
|
|
8
|
+
coverage: {
|
|
9
|
+
provider: "v8",
|
|
10
|
+
include: ["src/**/*.ts"],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|