@hotmeshio/hotmesh 0.16.3 → 0.16.4

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.16.3",
3
+ "version": "0.16.4",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -6,6 +6,8 @@ const pipe_1 = require("../pipe");
6
6
  const task_1 = require("../task");
7
7
  const telemetry_1 = require("../telemetry");
8
8
  const stream_1 = require("../../types/stream");
9
+ const errors_1 = require("../../modules/errors");
10
+ const collator_2 = require("../../types/collator");
9
11
  const utils_1 = require("../../modules/utils");
10
12
  const activity_1 = require("./activity");
11
13
  /**
@@ -293,9 +295,38 @@ class Hook extends activity_1.Activity {
293
295
  this.context.metadata.jid = jobId;
294
296
  this.context.metadata.gid = gId;
295
297
  this.context.metadata.dad = dad;
296
- await this.processEvent(status, code, 'hook');
297
- if (code === 200) {
298
- await taskService.deleteWebHookSignal(this.config.hook.topic, data);
298
+ // Inline retry for FORBIDDEN: Leg2 arrived in the window between
299
+ // setHookSignal (standalone) and Leg1 transaction.exec(). The 100B
300
+ // ledger digit is not yet visible. Leg1 needs only milliseconds to
301
+ // commit — retry here, inside the message processing loop, before
302
+ // consumeOne's finally block acks the message. Stream-level retry
303
+ // won't help: ENGINE consumers have no retry policy, so shouldRetry
304
+ // returns [false, 0] and the message is ack'd with no retry.
305
+ const MAX_FORBIDDEN_RETRIES = 5;
306
+ const FORBIDDEN_RETRY_DELAY_MS = 50;
307
+ for (let attempt = 0; attempt <= MAX_FORBIDDEN_RETRIES; attempt++) {
308
+ try {
309
+ await this.processEvent(status, code, 'hook');
310
+ if (code === 200) {
311
+ await taskService.deleteWebHookSignal(this.config.hook.topic, data);
312
+ }
313
+ return;
314
+ }
315
+ catch (error) {
316
+ if (error instanceof errors_1.CollationError &&
317
+ error.fault === collator_2.CollationFaultType.FORBIDDEN &&
318
+ attempt < MAX_FORBIDDEN_RETRIES) {
319
+ this.logger.warn('hook-webhook-forbidden-inline-retry', {
320
+ attempt: attempt + 1,
321
+ maxAttempts: MAX_FORBIDDEN_RETRIES,
322
+ jid: this.context.metadata.jid,
323
+ aid: this.metadata.aid,
324
+ });
325
+ await (0, utils_1.sleepFor)(FORBIDDEN_RETRY_DELAY_MS * (attempt + 1));
326
+ continue;
327
+ }
328
+ throw error;
329
+ }
299
330
  }
300
331
  }
301
332
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.16.3",
3
+ "version": "0.16.4",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",