squiss-ts 5.2.1 → 5.2.3
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/dist/Squiss.d.ts +1 -0
- package/dist/Squiss.js +22 -12
- package/dist/TimeoutExtender.js +3 -1
- package/package.json +23 -15
package/dist/Squiss.d.ts
CHANGED
package/dist/Squiss.js
CHANGED
|
@@ -79,9 +79,9 @@ class Squiss extends events_1.EventEmitter {
|
|
|
79
79
|
return res.QueueUrl;
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
deleteMessage(msg) {
|
|
82
|
+
async deleteMessage(msg) {
|
|
83
83
|
if (!msg.raw) {
|
|
84
|
-
|
|
84
|
+
throw new Error('Squiss.deleteMessage requires a Message object');
|
|
85
85
|
}
|
|
86
86
|
const promise = new Promise((resolve, reject) => {
|
|
87
87
|
this._delQueue.set(msg.raw.MessageId, { msg, Id: msg.raw.MessageId, ReceiptHandle: msg.raw.ReceiptHandle, resolve, reject });
|
|
@@ -94,12 +94,12 @@ class Squiss extends events_1.EventEmitter {
|
|
|
94
94
|
clearTimeout(this._delTimer);
|
|
95
95
|
this._delTimer = undefined;
|
|
96
96
|
}
|
|
97
|
-
this._deleteXMessages(this._opts.deleteBatchSize);
|
|
97
|
+
await this._deleteXMessages(this._opts.deleteBatchSize);
|
|
98
98
|
}
|
|
99
99
|
else if (!this._delTimer) {
|
|
100
|
-
this._delTimer = setTimeout(() => {
|
|
100
|
+
this._delTimer = setTimeout(async () => {
|
|
101
101
|
this._delTimer = undefined;
|
|
102
|
-
this._deleteXMessages();
|
|
102
|
+
await this._deleteXMessages();
|
|
103
103
|
}, this._opts.deleteWaitMs);
|
|
104
104
|
}
|
|
105
105
|
return promise;
|
|
@@ -145,7 +145,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
145
145
|
}
|
|
146
146
|
/* istanbul ignore if */
|
|
147
147
|
if (!newUrl) {
|
|
148
|
-
throw new Error(
|
|
148
|
+
throw new Error('Failed to get configured SQQ endpoint');
|
|
149
149
|
}
|
|
150
150
|
const parsedQueueUrl = new url_1.URL(this._queueUrl);
|
|
151
151
|
newUrl.pathname = parsedQueueUrl.pathname;
|
|
@@ -268,17 +268,18 @@ class Squiss extends events_1.EventEmitter {
|
|
|
268
268
|
this._running = true;
|
|
269
269
|
return this._startPoller();
|
|
270
270
|
}
|
|
271
|
-
stop(soft, timeout) {
|
|
271
|
+
async stop(soft, timeout) {
|
|
272
272
|
if (!soft && this._activeReq) {
|
|
273
273
|
this._activeReq.abort();
|
|
274
274
|
}
|
|
275
275
|
this._running = this._paused = false;
|
|
276
276
|
if (!this._inFlight) {
|
|
277
|
-
|
|
277
|
+
await this._drainDeleteQueue();
|
|
278
|
+
return true;
|
|
278
279
|
}
|
|
279
280
|
let resolved = false;
|
|
280
281
|
let timer;
|
|
281
|
-
|
|
282
|
+
const result = await new Promise(async (resolve) => {
|
|
282
283
|
this.on('drained', () => {
|
|
283
284
|
if (!resolved) {
|
|
284
285
|
resolved = true;
|
|
@@ -294,6 +295,8 @@ class Squiss extends events_1.EventEmitter {
|
|
|
294
295
|
resolve(false);
|
|
295
296
|
}, timeout) : undefined;
|
|
296
297
|
});
|
|
298
|
+
await this._drainDeleteQueue();
|
|
299
|
+
return result;
|
|
297
300
|
}
|
|
298
301
|
getS3() {
|
|
299
302
|
if (!this._s3) {
|
|
@@ -301,6 +304,13 @@ class Squiss extends events_1.EventEmitter {
|
|
|
301
304
|
}
|
|
302
305
|
return this._s3;
|
|
303
306
|
}
|
|
307
|
+
async _drainDeleteQueue() {
|
|
308
|
+
if (this._delTimer) {
|
|
309
|
+
clearTimeout(this._delTimer);
|
|
310
|
+
this._delTimer = undefined;
|
|
311
|
+
}
|
|
312
|
+
await this._deleteXMessages();
|
|
313
|
+
}
|
|
304
314
|
_initS3() {
|
|
305
315
|
if (this._opts.S3) {
|
|
306
316
|
if (typeof this._opts.S3 === 'function') {
|
|
@@ -446,7 +456,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
446
456
|
this._getBatch(queueUrl);
|
|
447
457
|
});
|
|
448
458
|
}
|
|
449
|
-
_deleteXMessages(x) {
|
|
459
|
+
async _deleteXMessages(x) {
|
|
450
460
|
const delQueue = this._delQueue;
|
|
451
461
|
const iterator = delQueue.entries();
|
|
452
462
|
const delBatch = Array.from({ length: x || delQueue.size }, function () {
|
|
@@ -454,7 +464,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
454
464
|
delQueue.delete(element[0]);
|
|
455
465
|
return element[1];
|
|
456
466
|
}, iterator);
|
|
457
|
-
this._deleteMessages(delBatch);
|
|
467
|
+
await this._deleteMessages(delBatch);
|
|
458
468
|
}
|
|
459
469
|
_isLargeMessage(message, minSize) {
|
|
460
470
|
const messageSize = (0, messageSizeUtils_1.getMessageSize)(message);
|
|
@@ -480,7 +490,7 @@ class Squiss extends events_1.EventEmitter {
|
|
|
480
490
|
getMessagePromise = (0, gzipUtils_1.compressMessage)(messageStr);
|
|
481
491
|
params.MessageAttributes = params.MessageAttributes || {};
|
|
482
492
|
params.MessageAttributes[gzipUtils_1.GZIP_MARKER] = {
|
|
483
|
-
StringValue:
|
|
493
|
+
StringValue: '1',
|
|
484
494
|
DataType: 'Number',
|
|
485
495
|
};
|
|
486
496
|
}
|
package/dist/TimeoutExtender.js
CHANGED
|
@@ -97,7 +97,9 @@ class TimeoutExtender {
|
|
|
97
97
|
})
|
|
98
98
|
.catch((err) => {
|
|
99
99
|
if (err.name === 'ReceiptHandleIsInvalid' || err.name === 'MessageNotInflight' ||
|
|
100
|
-
err.message.match(/
|
|
100
|
+
err.message.match(/message does not exist or is not available/i) ||
|
|
101
|
+
err.message.match(/the receipt handle has expired/i) ||
|
|
102
|
+
err.message.match(/not a valid receipt handle/i)) {
|
|
101
103
|
this._deleteNode(node);
|
|
102
104
|
node.message.emit('autoExtendFail', err);
|
|
103
105
|
this._squiss.emit('autoExtendFail', { message: node.message, error: err });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squiss-ts",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.3",
|
|
4
4
|
"description": "High-volume SQS poller",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"compile": "tsc",
|
|
14
14
|
"test": "yarn lint && yarn mocha",
|
|
15
15
|
"cover": "yarn clean && yarn nyc yarn mocha",
|
|
16
|
-
"lint": "
|
|
16
|
+
"lint": "eslint -c .eslintrc.js --ext .ts \"src/**/*.ts\"",
|
|
17
17
|
"benchmark": "tsc --extendedDiagnostics --incremental false",
|
|
18
18
|
"e2e:start": "docker compose -f e2e/docker-compose.yml up &",
|
|
19
19
|
"e2e:stop": "docker compose -f e2e/docker-compose.yml down &"
|
|
@@ -48,34 +48,40 @@
|
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/PruvoNet/squiss-ts#readme",
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@aws-sdk/client-s3": "^3.
|
|
52
|
-
"@aws-sdk/client-sqs": "^3.
|
|
53
|
-
"@aws-sdk/types": "^3.
|
|
51
|
+
"@aws-sdk/client-s3": "^3.410.0",
|
|
52
|
+
"@aws-sdk/client-sqs": "^3.410.0",
|
|
53
|
+
"@aws-sdk/types": "^3.410.0",
|
|
54
54
|
"linked-list": "2.1.0",
|
|
55
55
|
"ts-type-guards": "^0.7.0",
|
|
56
|
-
"uuid": "^9.0.
|
|
56
|
+
"uuid": "^9.0.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@istanbuljs/nyc-config-typescript": "1.0.2",
|
|
60
|
-
"@types/chai": "^4.3.
|
|
61
|
-
"@types/chai-as-promised": "^7.1.
|
|
60
|
+
"@types/chai": "^4.3.6",
|
|
61
|
+
"@types/chai-as-promised": "^7.1.6",
|
|
62
62
|
"@types/mocha": "^10.0.1",
|
|
63
|
-
"@types/node": "^
|
|
63
|
+
"@types/node": "^16.18.39",
|
|
64
64
|
"@types/proxyquire": "^1.3.28",
|
|
65
|
-
"@types/uuid": "^9.0.
|
|
66
|
-
"
|
|
65
|
+
"@types/uuid": "^9.0.3",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
67
|
+
"@typescript-eslint/parser": "^6.7.0",
|
|
68
|
+
"chai": "^4.3.8",
|
|
67
69
|
"chai-as-promised": "^7.1.1",
|
|
68
70
|
"delay": "5.0.0",
|
|
69
71
|
"dirty-chai": "^2.0.1",
|
|
72
|
+
"eslint": "^8.49.0",
|
|
73
|
+
"eslint-config-prettier": "^9.0.0",
|
|
74
|
+
"eslint-plugin-import": "^2.28.1",
|
|
75
|
+
"eslint-plugin-jsdoc": "^46.6.0",
|
|
76
|
+
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
70
77
|
"mocha": "^10.2.0",
|
|
71
78
|
"nyc": "^15.1.0",
|
|
72
79
|
"proxyquire": "^2.1.3",
|
|
73
|
-
"sinon": "^15.
|
|
80
|
+
"sinon": "^15.2.0",
|
|
74
81
|
"sinon-chai": "^3.7.0",
|
|
75
82
|
"source-map-support": "^0.5.21",
|
|
76
83
|
"ts-node": "^10.9.1",
|
|
77
|
-
"
|
|
78
|
-
"typescript": "^5.1.3"
|
|
84
|
+
"typescript": "^5.2.2"
|
|
79
85
|
},
|
|
80
86
|
"nyc": {
|
|
81
87
|
"extends": "@istanbuljs/nyc-config-typescript",
|
|
@@ -83,7 +89,9 @@
|
|
|
83
89
|
"all": true,
|
|
84
90
|
"exclude": [
|
|
85
91
|
"src/test/**",
|
|
86
|
-
"e2e**"
|
|
92
|
+
"e2e**",
|
|
93
|
+
"build**",
|
|
94
|
+
".eslintrc.js"
|
|
87
95
|
],
|
|
88
96
|
"reporter": [
|
|
89
97
|
"html",
|