@checkstack/queue-memory-backend 0.4.27 → 0.4.29

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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @checkstack/queue-memory-backend
2
2
 
3
+ ## 0.4.29
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [390d9cf]
8
+ - @checkstack/backend-api@0.30.0
9
+
10
+ ## 0.4.28
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [c55d7c6]
15
+ - @checkstack/common@0.21.0
16
+ - @checkstack/backend-api@0.29.1
17
+ - @checkstack/queue-api@0.3.18
18
+ - @checkstack/queue-memory-common@0.1.26
19
+
3
20
  ## 0.4.27
4
21
 
5
22
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/queue-memory-backend",
3
- "version": "0.4.27",
3
+ "version": "0.4.29",
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.29.0",
21
- "@checkstack/queue-api": "0.3.17",
22
- "@checkstack/queue-memory-common": "0.1.25",
23
- "@checkstack/common": "0.20.0",
20
+ "@checkstack/backend-api": "0.30.0",
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.1"
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("should handle long delays by chunking timeouts", async () => {
215
- queue = createTestQueue("test-max-timeout");
216
-
217
- let executionCount = 0;
218
- await queue.consume(
219
- async () => {
220
- executionCount++;
221
- },
222
- { consumerGroup: "test", maxRetries: 0 },
223
- );
224
-
225
- // Schedule monthly cron (1st of each month at midnight)
226
- // Starting from Jan 18, next run is Feb 1 = ~14 days
227
- await queue.scheduleRecurring("payload", {
228
- jobId: "monthly-cron",
229
- cronPattern: "0 0 1 * *",
230
- });
231
-
232
- // Advance 10 days - should not have executed yet
233
- jest.advanceTimersByTime(10 * 24 * 60 * 60 * 1000);
234
- await Promise.resolve();
235
- expect(executionCount).toBe(0);
236
-
237
- // Advance 5 more days to pass Feb 1 (total 15 days)
238
- jest.advanceTimersByTime(5 * 24 * 60 * 60 * 1000);
239
- await Promise.resolve();
240
-
241
- // Now it should have executed on Feb 1
242
- expect(executionCount).toBeGreaterThanOrEqual(1);
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
@@ -215,25 +215,38 @@ describe("InMemoryQueue Consumer Groups", () => {
215
215
  }
216
216
  });
217
217
 
218
- it("should not retry beyond maxRetries", async () => {
219
- let attempts = 0;
220
-
221
- await queue.consume(
222
- async () => {
223
- attempts++;
224
- throw new Error("Always fails");
225
- },
226
- { consumerGroup: "fail-group", maxRetries: 2 },
227
- );
228
-
229
- await queue.enqueue("test");
230
-
231
- // Wait for all retries (with delayMultiplier=0.01: ~60ms total)
232
- await new Promise((resolve) => setTimeout(resolve, 150));
233
-
234
- // Should try 3 times total (initial + 2 retries)
235
- expect(attempts).toBe(3);
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", () => {