@hogsend/engine 0.38.1 → 0.38.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hogsend/engine",
3
- "version": "0.38.1",
3
+ "version": "0.38.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -42,14 +42,14 @@
42
42
  "svix": "^1.95.1",
43
43
  "winston": "^3.19.0",
44
44
  "zod": "^4.4.3",
45
- "@hogsend/core": "^0.38.1",
46
- "@hogsend/db": "^0.38.1",
47
- "@hogsend/email": "^0.38.1",
48
- "@hogsend/plugin-posthog": "^0.38.1",
49
- "@hogsend/plugin-resend": "^0.38.1"
45
+ "@hogsend/core": "^0.38.2",
46
+ "@hogsend/db": "^0.38.2",
47
+ "@hogsend/email": "^0.38.2",
48
+ "@hogsend/plugin-posthog": "^0.38.2",
49
+ "@hogsend/plugin-resend": "^0.38.2"
50
50
  },
51
51
  "optionalDependencies": {
52
- "@hogsend/plugin-postmark": "^0.38.1"
52
+ "@hogsend/plugin-postmark": "^0.38.2"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^22.15.3",
@@ -12,3 +12,12 @@
12
12
  */
13
13
  export const JOURNEY_EXECUTION_TIMEOUT_HOURS = 720;
14
14
  export const JOURNEY_EXECUTION_TIMEOUT = `${JOURNEY_EXECUTION_TIMEOUT_HOURS}h`;
15
+
16
+ /**
17
+ * Max time a journey task may wait in the queue for a worker slot before Hatchet
18
+ * cancels it (`scheduleTimeout`). The SDK default (~5m) is too tight for a
19
+ * durable-wait RESUME that re-queues during a redeploy when every worker slot is
20
+ * momentarily saturated — the resume would be cancelled and the enrollment
21
+ * stranded. 15m gives resumes head-room to land on a freed slot.
22
+ */
23
+ export const JOURNEY_SCHEDULE_TIMEOUT = "15m";
@@ -19,7 +19,10 @@ import { createLogger } from "../lib/logger.js";
19
19
  import { emitOutbound } from "../lib/outbound.js";
20
20
  import { resolveTimezoneWithSource } from "../lib/timezone.js";
21
21
  import { getClientScheduleDefaults } from "./client-defaults-singleton.js";
22
- import { JOURNEY_EXECUTION_TIMEOUT } from "./constants.js";
22
+ import {
23
+ JOURNEY_EXECUTION_TIMEOUT,
24
+ JOURNEY_SCHEDULE_TIMEOUT,
25
+ } from "./constants.js";
23
26
  import { JourneyExitedError } from "./errors.js";
24
27
  import {
25
28
  createMemoize,
@@ -93,7 +96,20 @@ export function defineJourney(options: {
93
96
  name: `journey-${meta.id}`,
94
97
  onEvents: [meta.trigger.event],
95
98
  executionTimeout: JOURNEY_EXECUTION_TIMEOUT,
99
+ // retries STAYS 0 — deliberately. A retry replays `run()` from the top, and
100
+ // the tracked mailer / connector machinery is "missed > doubled": a `queued`
101
+ // row is RE-DRIVEN and a failed send NULLs its idempotency key (tracked.ts
102
+ // ~150-176, 496-514). That is safe only while nothing re-invokes a run whose
103
+ // `provider.send()` already delivered but whose durable status flip didn't
104
+ // commit — turning retries on would re-deliver that email/connector message
105
+ // (a DUPLICATE). Enabling retries requires making sends provider-idempotent
106
+ // first (Resend/Postmark `Idempotency-Key`); tracked as a follow-up.
96
107
  retries: 0,
108
+ // `scheduleTimeout` widens the queue-wait ceiling (SDK default ~5m) so a
109
+ // durable-wait RESUME re-queued during a redeploy's slot saturation reclaims
110
+ // a slot instead of being cancelled (which strands the enrollment). Unlike
111
+ // retries this adds NO replay — it is pure head-room, so it is safe on its own.
112
+ scheduleTimeout: JOURNEY_SCHEDULE_TIMEOUT,
97
113
  fn: async (input: EventPayloadInput, hatchetCtx) => {
98
114
  const db = getDb();
99
115
  const userId = input.userId as string;
@@ -230,9 +246,14 @@ export function defineJourney(options: {
230
246
  // Independent I/O — fetch the contact row and PostHog person props
231
247
  // concurrently. PostHog failures fall through to undefined.
232
248
  const [contact, posthogProperties] = await Promise.all([
233
- db.query.contacts.findFirst({
234
- where: eq(contacts.externalId, userId),
235
- }),
249
+ // Both legs are best-effort tz inputs: a failure here must fall through
250
+ // to the client-default tz, never reject the `Promise.all` and throw out
251
+ // of `fn` BEFORE the try/catch below (which would strand the row —
252
+ // already inserted "active" — outside the failure handling). The PostHog
253
+ // leg already `.catch`es; mirror it on the contact read.
254
+ db.query.contacts
255
+ .findFirst({ where: eq(contacts.externalId, userId) })
256
+ .catch(() => undefined),
236
257
  posthog?.getPersonProperties(userId).catch(() => undefined),
237
258
  ]);
238
259