@checkstack/queue-memory-backend 0.4.26 → 0.4.28
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 +20 -0
- package/package.json +6 -6
- package/src/cron-scheduling.test.ts +37 -30
- package/src/memory-queue.test.ts +32 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @checkstack/queue-memory-backend
|
|
2
2
|
|
|
3
|
+
## 0.4.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [c55d7c6]
|
|
8
|
+
- @checkstack/common@0.21.0
|
|
9
|
+
- @checkstack/backend-api@0.29.1
|
|
10
|
+
- @checkstack/queue-api@0.3.18
|
|
11
|
+
- @checkstack/queue-memory-common@0.1.26
|
|
12
|
+
|
|
13
|
+
## 0.4.27
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [faf98f5]
|
|
18
|
+
- @checkstack/backend-api@0.29.0
|
|
19
|
+
- @checkstack/common@0.20.0
|
|
20
|
+
- @checkstack/queue-api@0.3.17
|
|
21
|
+
- @checkstack/queue-memory-common@0.1.25
|
|
22
|
+
|
|
3
23
|
## 0.4.26
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/queue-memory-backend",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"checkstack": {
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"pack": "bunx @checkstack/scripts plugin-pack"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@checkstack/backend-api": "0.
|
|
21
|
-
"@checkstack/queue-api": "0.3.
|
|
22
|
-
"@checkstack/queue-memory-common": "0.1.
|
|
23
|
-
"@checkstack/common": "0.
|
|
20
|
+
"@checkstack/backend-api": "0.29.1",
|
|
21
|
+
"@checkstack/queue-api": "0.3.18",
|
|
22
|
+
"@checkstack/queue-memory-common": "0.1.26",
|
|
23
|
+
"@checkstack/common": "0.21.0",
|
|
24
24
|
"cron-parser": "^4.9.0",
|
|
25
25
|
"zod": "^4.2.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/bun": "latest",
|
|
29
29
|
"@checkstack/tsconfig": "0.0.7",
|
|
30
|
-
"@checkstack/scripts": "0.7.
|
|
30
|
+
"@checkstack/scripts": "0.7.2"
|
|
31
31
|
},
|
|
32
32
|
"description": "Checkstack queue-memory-backend plugin",
|
|
33
33
|
"author": {
|
|
@@ -211,36 +211,43 @@ describe("InMemoryQueue Cron Scheduling", () => {
|
|
|
211
211
|
});
|
|
212
212
|
|
|
213
213
|
describe("MAX_TIMEOUT handling", () => {
|
|
214
|
-
it(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
214
|
+
it(
|
|
215
|
+
"should handle long delays by chunking timeouts",
|
|
216
|
+
async () => {
|
|
217
|
+
queue = createTestQueue("test-max-timeout");
|
|
218
|
+
|
|
219
|
+
let executionCount = 0;
|
|
220
|
+
await queue.consume(
|
|
221
|
+
async () => {
|
|
222
|
+
executionCount++;
|
|
223
|
+
},
|
|
224
|
+
{ consumerGroup: "test", maxRetries: 0 },
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
// Schedule monthly cron (1st of each month at midnight)
|
|
228
|
+
// Starting from Jan 18, next run is Feb 1 = ~14 days
|
|
229
|
+
await queue.scheduleRecurring("payload", {
|
|
230
|
+
jobId: "monthly-cron",
|
|
231
|
+
cronPattern: "0 0 1 * *",
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Advance 10 days - should not have executed yet
|
|
235
|
+
jest.advanceTimersByTime(10 * 24 * 60 * 60 * 1000);
|
|
236
|
+
await Promise.resolve();
|
|
237
|
+
expect(executionCount).toBe(0);
|
|
238
|
+
|
|
239
|
+
// Advance 5 more days to pass Feb 1 (total 15 days)
|
|
240
|
+
jest.advanceTimersByTime(5 * 24 * 60 * 60 * 1000);
|
|
241
|
+
await Promise.resolve();
|
|
242
|
+
|
|
243
|
+
// Now it should have executed on Feb 1
|
|
244
|
+
expect(executionCount).toBeGreaterThanOrEqual(1);
|
|
245
|
+
},
|
|
246
|
+
// Advancing 15 days of chunked fake timers walks a long chain of
|
|
247
|
+
// rescheduled timeouts; under full-suite load that legitimately
|
|
248
|
+
// exceeds the default 5s test timeout.
|
|
249
|
+
15_000,
|
|
250
|
+
);
|
|
244
251
|
|
|
245
252
|
it("should chunk timeouts longer than MAX_TIMEOUT", async () => {
|
|
246
253
|
// Note: Bun's setSystemTime and jest.advanceTimersByTime use
|
package/src/memory-queue.test.ts
CHANGED
|
@@ -215,25 +215,38 @@ describe("InMemoryQueue Consumer Groups", () => {
|
|
|
215
215
|
}
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
-
it(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
218
|
+
it(
|
|
219
|
+
"should not retry beyond maxRetries",
|
|
220
|
+
async () => {
|
|
221
|
+
let attempts = 0;
|
|
222
|
+
|
|
223
|
+
await queue.consume(
|
|
224
|
+
async () => {
|
|
225
|
+
attempts++;
|
|
226
|
+
throw new Error("Always fails");
|
|
227
|
+
},
|
|
228
|
+
{ consumerGroup: "fail-group", maxRetries: 2 },
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
await queue.enqueue("test");
|
|
232
|
+
|
|
233
|
+
// Poll instead of a fixed sleep: the retries take ~60ms nominally
|
|
234
|
+
// (delayMultiplier=0.01), but under full-suite load the event loop
|
|
235
|
+
// can starve the retry timers well past that.
|
|
236
|
+
const deadline = Date.now() + 5000;
|
|
237
|
+
while (attempts < 3 && Date.now() < deadline) {
|
|
238
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Should try 3 times total (initial + 2 retries)...
|
|
242
|
+
expect(attempts).toBe(3);
|
|
243
|
+
|
|
244
|
+
// ...and never a 4th: give a would-be extra retry ample time to fire.
|
|
245
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
246
|
+
expect(attempts).toBe(3);
|
|
247
|
+
},
|
|
248
|
+
10_000,
|
|
249
|
+
);
|
|
237
250
|
});
|
|
238
251
|
|
|
239
252
|
describe("Mixed Patterns", () => {
|