@adonis-agora/durable 0.6.1 → 0.8.0

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.
Files changed (159) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +1 -1
  3. package/dist/commands/main.d.ts +3 -2
  4. package/dist/commands/main.d.ts.map +1 -1
  5. package/dist/commands/main.js +3 -2
  6. package/dist/commands/main.js.map +1 -1
  7. package/dist/commands/make_workflow.d.ts +4 -3
  8. package/dist/commands/make_workflow.d.ts.map +1 -1
  9. package/dist/commands/make_workflow.js +4 -3
  10. package/dist/commands/make_workflow.js.map +1 -1
  11. package/dist/configure.d.ts +6 -5
  12. package/dist/configure.d.ts.map +1 -1
  13. package/dist/configure.js +9 -6
  14. package/dist/configure.js.map +1 -1
  15. package/dist/providers/dashboard_provider.d.ts +34 -3
  16. package/dist/providers/dashboard_provider.d.ts.map +1 -1
  17. package/dist/providers/dashboard_provider.js +110 -6
  18. package/dist/providers/dashboard_provider.js.map +1 -1
  19. package/dist/providers/durable_provider.d.ts.map +1 -1
  20. package/dist/providers/durable_provider.js +41 -4
  21. package/dist/providers/durable_provider.js.map +1 -1
  22. package/dist/src/base-workflow.d.ts +78 -0
  23. package/dist/src/base-workflow.d.ts.map +1 -0
  24. package/dist/src/base-workflow.js +106 -0
  25. package/dist/src/base-workflow.js.map +1 -0
  26. package/dist/src/codec-state-store.d.ts +13 -0
  27. package/dist/src/codec-state-store.d.ts.map +1 -1
  28. package/dist/src/codec-state-store.js +13 -0
  29. package/dist/src/codec-state-store.js.map +1 -1
  30. package/dist/src/control-flow-signal.d.ts +50 -0
  31. package/dist/src/control-flow-signal.d.ts.map +1 -0
  32. package/dist/src/control-flow-signal.js +54 -0
  33. package/dist/src/control-flow-signal.js.map +1 -0
  34. package/dist/src/control-plane-redis/redis-control-plane.d.ts +57 -5
  35. package/dist/src/control-plane-redis/redis-control-plane.d.ts.map +1 -1
  36. package/dist/src/control-plane-redis/redis-control-plane.js +100 -2
  37. package/dist/src/control-plane-redis/redis-control-plane.js.map +1 -1
  38. package/dist/src/dashboard/auth.d.ts +89 -0
  39. package/dist/src/dashboard/auth.d.ts.map +1 -0
  40. package/dist/src/dashboard/auth.js +113 -0
  41. package/dist/src/dashboard/auth.js.map +1 -0
  42. package/dist/src/dashboard/define_config.d.ts +17 -0
  43. package/dist/src/dashboard/define_config.d.ts.map +1 -1
  44. package/dist/src/dashboard/define_config.js +23 -1
  45. package/dist/src/dashboard/define_config.js.map +1 -1
  46. package/dist/src/dashboard/index.d.ts +6 -1
  47. package/dist/src/dashboard/index.d.ts.map +1 -1
  48. package/dist/src/dashboard/index.js +5 -1
  49. package/dist/src/dashboard/index.js.map +1 -1
  50. package/dist/src/dashboard/login_page.d.ts +23 -0
  51. package/dist/src/dashboard/login_page.d.ts.map +1 -0
  52. package/dist/src/dashboard/login_page.js +170 -0
  53. package/dist/src/dashboard/login_page.js.map +1 -0
  54. package/dist/src/dashboard/session_cookie.d.ts +42 -0
  55. package/dist/src/dashboard/session_cookie.d.ts.map +1 -0
  56. package/dist/src/dashboard/session_cookie.js +97 -0
  57. package/dist/src/dashboard/session_cookie.js.map +1 -0
  58. package/dist/src/define_config.d.ts +11 -2
  59. package/dist/src/define_config.d.ts.map +1 -1
  60. package/dist/src/define_config.js.map +1 -1
  61. package/dist/src/engine.d.ts +91 -3
  62. package/dist/src/engine.d.ts.map +1 -1
  63. package/dist/src/engine.js +331 -44
  64. package/dist/src/engine.js.map +1 -1
  65. package/dist/src/entities.js +2 -2
  66. package/dist/src/entities.js.map +1 -1
  67. package/dist/src/errors.d.ts +6 -1
  68. package/dist/src/errors.d.ts.map +1 -1
  69. package/dist/src/errors.js +7 -2
  70. package/dist/src/errors.js.map +1 -1
  71. package/dist/src/event-accumulators.d.ts +1 -1
  72. package/dist/src/event-accumulators.d.ts.map +1 -1
  73. package/dist/src/events.d.ts +16 -0
  74. package/dist/src/events.d.ts.map +1 -1
  75. package/dist/src/events.js +26 -1
  76. package/dist/src/events.js.map +1 -1
  77. package/dist/src/hooks/steps.d.ts +43 -0
  78. package/dist/src/hooks/steps.d.ts.map +1 -0
  79. package/dist/src/hooks/steps.js +46 -0
  80. package/dist/src/hooks/steps.js.map +1 -0
  81. package/dist/src/hooks/workflows.d.ts +3 -2
  82. package/dist/src/hooks/workflows.d.ts.map +1 -1
  83. package/dist/src/hooks/workflows.js +3 -2
  84. package/dist/src/hooks/workflows.js.map +1 -1
  85. package/dist/src/index.d.ts +8 -2
  86. package/dist/src/index.d.ts.map +1 -1
  87. package/dist/src/index.js +8 -2
  88. package/dist/src/index.js.map +1 -1
  89. package/dist/src/interfaces.d.ts +160 -43
  90. package/dist/src/interfaces.d.ts.map +1 -1
  91. package/dist/src/services/main.d.ts +13 -0
  92. package/dist/src/services/main.d.ts.map +1 -0
  93. package/dist/src/services/main.js +17 -0
  94. package/dist/src/services/main.js.map +1 -0
  95. package/dist/src/step-discovery.d.ts +42 -0
  96. package/dist/src/step-discovery.d.ts.map +1 -0
  97. package/dist/src/step-discovery.js +127 -0
  98. package/dist/src/step-discovery.js.map +1 -0
  99. package/dist/src/step-name-symbol.d.ts +63 -0
  100. package/dist/src/step-name-symbol.d.ts.map +1 -0
  101. package/dist/src/step-name-symbol.js +42 -0
  102. package/dist/src/step-name-symbol.js.map +1 -0
  103. package/dist/src/step-ref.d.ts +70 -0
  104. package/dist/src/step-ref.d.ts.map +1 -0
  105. package/dist/src/step-ref.js +93 -0
  106. package/dist/src/step-ref.js.map +1 -0
  107. package/dist/src/stores/lucid-schema.d.ts +1 -0
  108. package/dist/src/stores/lucid-schema.d.ts.map +1 -1
  109. package/dist/src/stores/lucid-schema.js +15 -0
  110. package/dist/src/stores/lucid-schema.js.map +1 -1
  111. package/dist/src/stores/lucid.d.ts +13 -0
  112. package/dist/src/stores/lucid.d.ts.map +1 -1
  113. package/dist/src/stores/lucid.js +43 -0
  114. package/dist/src/stores/lucid.js.map +1 -1
  115. package/dist/src/tenant-group.d.ts +18 -0
  116. package/dist/src/tenant-group.d.ts.map +1 -0
  117. package/dist/src/tenant-group.js +24 -0
  118. package/dist/src/tenant-group.js.map +1 -0
  119. package/dist/src/testing/in-memory-state-store.d.ts +16 -0
  120. package/dist/src/testing/in-memory-state-store.d.ts.map +1 -1
  121. package/dist/src/testing/in-memory-state-store.js +29 -0
  122. package/dist/src/testing/in-memory-state-store.js.map +1 -1
  123. package/dist/src/testing-kit/state-store-conformance.d.ts.map +1 -1
  124. package/dist/src/testing-kit/state-store-conformance.js +33 -2
  125. package/dist/src/testing-kit/state-store-conformance.js.map +1 -1
  126. package/dist/src/testing-kit/transport-conformance.d.ts.map +1 -1
  127. package/dist/src/testing-kit/transport-conformance.js +7 -12
  128. package/dist/src/testing-kit/transport-conformance.js.map +1 -1
  129. package/dist/src/transports/db.d.ts +14 -5
  130. package/dist/src/transports/db.d.ts.map +1 -1
  131. package/dist/src/transports/db.js +20 -15
  132. package/dist/src/transports/db.js.map +1 -1
  133. package/dist/src/transports/queue.d.ts +15 -5
  134. package/dist/src/transports/queue.d.ts.map +1 -1
  135. package/dist/src/transports/queue.js +19 -17
  136. package/dist/src/transports/queue.js.map +1 -1
  137. package/dist/src/workflow-als.d.ts +21 -0
  138. package/dist/src/workflow-als.d.ts.map +1 -0
  139. package/dist/src/workflow-als.js +22 -0
  140. package/dist/src/workflow-als.js.map +1 -0
  141. package/dist/src/workflow-ctx.d.ts +27 -8
  142. package/dist/src/workflow-ctx.d.ts.map +1 -1
  143. package/dist/src/workflow-ctx.js +183 -19
  144. package/dist/src/workflow-ctx.js.map +1 -1
  145. package/dist/src/workflow-discovery.d.ts +21 -15
  146. package/dist/src/workflow-discovery.d.ts.map +1 -1
  147. package/dist/src/workflow-discovery.js +17 -13
  148. package/dist/src/workflow-discovery.js.map +1 -1
  149. package/dist/src/workflow-ref.d.ts +9 -27
  150. package/dist/src/workflow-ref.d.ts.map +1 -1
  151. package/dist/src/workflow-ref.js +12 -34
  152. package/dist/src/workflow-ref.js.map +1 -1
  153. package/dist/stubs/database/migrations/create_durable_tables.stub +13 -1
  154. package/dist/stubs/make/workflow/main.stub +5 -4
  155. package/package.json +11 -1
  156. package/dist/src/remote-step-factory.d.ts +0 -15
  157. package/dist/src/remote-step-factory.d.ts.map +0 -1
  158. package/dist/src/remote-step-factory.js +0 -12
  159. package/dist/src/remote-step-factory.js.map +0 -1
@@ -0,0 +1,78 @@
1
+ import { WorkflowEngine } from './engine.js';
2
+ import type { StartOptions } from './engine.js';
3
+ import type { WorkflowCtx } from './interfaces.js';
4
+ import type { WorkflowClass, WorkflowInputOf, WorkflowOptions, WorkflowOutputOf } from './workflow-ref.js';
5
+ /**
6
+ * Options for `BaseWorkflow`'s static `start`/`dispatch`. A superset of {@link StartOptions} (priority,
7
+ * namespace, tags, searchAttributes) plus an explicit `runId`:
8
+ * - **Outside** a running workflow, `runId` sets the new run's id; omitted → a fresh `randomUUID()`.
9
+ * - **Inside** a running workflow, `runId` is the deterministic child id; omitted → the ctx derives a
10
+ * replay-stable id from the call position (DO NOT pass a random one — it breaks determinism).
11
+ */
12
+ export type WorkflowDispatchOptions = {
13
+ runId?: string | undefined;
14
+ } & StartOptions;
15
+ /**
16
+ * How `BaseWorkflow`'s OUTSIDE static path locates the {@link WorkflowEngine}. Defaults to resolving
17
+ * the engine from the AdonisJS container (a module-singleton locator, exactly how a queue `Job`
18
+ * resolves its manager). Tests (or advanced embeddings) override it with {@link setWorkflowEngineResolver}
19
+ * to inject a specific engine without booting an application.
20
+ */
21
+ export type WorkflowEngineResolver = () => WorkflowEngine | Promise<WorkflowEngine>;
22
+ /**
23
+ * Override how `BaseWorkflow.start`/`dispatch` resolve the engine when called OUTSIDE a running
24
+ * workflow. Pass a resolver returning the engine to use; pass `undefined` to restore the default
25
+ * (container lookup). Primarily a testing seam — inject an in-memory engine, then reset in teardown.
26
+ */
27
+ export declare function setWorkflowEngineResolver(resolver: WorkflowEngineResolver | undefined): void;
28
+ /**
29
+ * Base class for a durable workflow. Declare the workflow's identity as a
30
+ * `static workflow = { name, version }` config and implement `run(ctx, input)`:
31
+ *
32
+ * ```ts
33
+ * export default class CheckoutWorkflow extends BaseWorkflow {
34
+ * static workflow = { name: 'checkout', version: '1' }
35
+ * async run(ctx: WorkflowCtx, order: Order) { … }
36
+ * }
37
+ * ```
38
+ *
39
+ * The static `workflow` config is resolved through `workflowName()` and registered via
40
+ * `app/workflows` auto-discovery.
41
+ *
42
+ * ## Context-aware dispatch
43
+ * The statics behave differently depending on whether they're called inside or outside a running
44
+ * workflow body (detected via the ambient ctx — see {@link getCurrentWorkflowCtx}):
45
+ *
46
+ * | | OUTSIDE (controller/service/script) | INSIDE a running workflow body |
47
+ * |------------|----------------------------------------------------------|---------------------------------------|
48
+ * | `.start` | `engine.start` + `waitForRun` → blocks, returns result | `ctx.child` → linked child, awaits it |
49
+ * | `.dispatch`| `engine.start` → fire-and-forget, returns `{ runId }` | `ctx.startChild` → fire-and-forget |
50
+ *
51
+ * `.start` always means "I want the result"; `.dispatch` always means "fire and forget" — in both
52
+ * contexts. Inside a workflow, routing through `ctx.child`/`ctx.startChild` (never the engine) is what
53
+ * keeps the run deterministic and replay-safe.
54
+ */
55
+ export declare abstract class BaseWorkflow {
56
+ /**
57
+ * The workflow's identity + options. Read by `workflowMeta()`/`workflowName()` and by
58
+ * `app/workflows` auto-discovery. Omit it and the class is not a registrable workflow.
59
+ */
60
+ static workflow?: WorkflowOptions;
61
+ /** The workflow body. `ctx` is the durable context; `input` is the run's typed input. */
62
+ abstract run(ctx: WorkflowCtx, input: unknown): unknown;
63
+ /**
64
+ * Start a run and **wait for its result**. Outside a workflow, enqueues via the engine and blocks
65
+ * until the run settles, returning its output. Inside a running workflow, starts a **linked child**
66
+ * (`ctx.child`) — the parent suspends until the child settles — and returns the child's output.
67
+ */
68
+ static start<C extends WorkflowClass>(this: C, input: WorkflowInputOf<C>, opts?: WorkflowDispatchOptions): Promise<WorkflowOutputOf<C>>;
69
+ /**
70
+ * Start a run **fire-and-forget** and return its `{ runId }` without waiting. Outside a workflow,
71
+ * enqueues via the engine and returns immediately. Inside a running workflow, kicks off a
72
+ * fire-and-forget child (`ctx.startChild`) — the parent keeps running — and returns the child id.
73
+ */
74
+ static dispatch<C extends WorkflowClass>(this: C, input: WorkflowInputOf<C>, opts?: WorkflowDispatchOptions): Promise<{
75
+ runId: string;
76
+ }>;
77
+ }
78
+ //# sourceMappingURL=base-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-workflow.d.ts","sourceRoot":"","sources":["../../src/base-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAAG,YAAY,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAIpF;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,GAAG,IAAI,CAE5F;AAWD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,8BAAsB,YAAY;IAChC;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAElC,yFAAyF;IACzF,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO;IAEvD;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,aAAa,EAClC,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EACzB,IAAI,CAAC,EAAE,uBAAuB,GAC7B,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAwB/B;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,aAAa,EACrC,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,EACzB,IAAI,CAAC,EAAE,uBAAuB,GAC7B,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAkB9B"}
@@ -0,0 +1,106 @@
1
+ import { WorkflowEngine } from './engine.js';
2
+ import { getCurrentWorkflowCtx } from './workflow-als.js';
3
+ let engineResolver;
4
+ /**
5
+ * Override how `BaseWorkflow.start`/`dispatch` resolve the engine when called OUTSIDE a running
6
+ * workflow. Pass a resolver returning the engine to use; pass `undefined` to restore the default
7
+ * (container lookup). Primarily a testing seam — inject an in-memory engine, then reset in teardown.
8
+ */
9
+ export function setWorkflowEngineResolver(resolver) {
10
+ engineResolver = resolver;
11
+ }
12
+ /** Resolve the engine for the OUTSIDE path: the injected resolver if set, else the app container. */
13
+ async function resolveEngine() {
14
+ if (engineResolver)
15
+ return engineResolver();
16
+ // Lazy import so the module-singleton `app` locator is only touched on the outside path, and so
17
+ // importing `BaseWorkflow` never eagerly pulls in `@adonisjs/core` (mirrors queue `Job.dispatch`).
18
+ const app = (await import('@adonisjs/core/services/app')).default;
19
+ return app.container.make(WorkflowEngine);
20
+ }
21
+ /**
22
+ * Base class for a durable workflow. Declare the workflow's identity as a
23
+ * `static workflow = { name, version }` config and implement `run(ctx, input)`:
24
+ *
25
+ * ```ts
26
+ * export default class CheckoutWorkflow extends BaseWorkflow {
27
+ * static workflow = { name: 'checkout', version: '1' }
28
+ * async run(ctx: WorkflowCtx, order: Order) { … }
29
+ * }
30
+ * ```
31
+ *
32
+ * The static `workflow` config is resolved through `workflowName()` and registered via
33
+ * `app/workflows` auto-discovery.
34
+ *
35
+ * ## Context-aware dispatch
36
+ * The statics behave differently depending on whether they're called inside or outside a running
37
+ * workflow body (detected via the ambient ctx — see {@link getCurrentWorkflowCtx}):
38
+ *
39
+ * | | OUTSIDE (controller/service/script) | INSIDE a running workflow body |
40
+ * |------------|----------------------------------------------------------|---------------------------------------|
41
+ * | `.start` | `engine.start` + `waitForRun` → blocks, returns result | `ctx.child` → linked child, awaits it |
42
+ * | `.dispatch`| `engine.start` → fire-and-forget, returns `{ runId }` | `ctx.startChild` → fire-and-forget |
43
+ *
44
+ * `.start` always means "I want the result"; `.dispatch` always means "fire and forget" — in both
45
+ * contexts. Inside a workflow, routing through `ctx.child`/`ctx.startChild` (never the engine) is what
46
+ * keeps the run deterministic and replay-safe.
47
+ */
48
+ export class BaseWorkflow {
49
+ /**
50
+ * The workflow's identity + options. Read by `workflowMeta()`/`workflowName()` and by
51
+ * `app/workflows` auto-discovery. Omit it and the class is not a registrable workflow.
52
+ */
53
+ static workflow;
54
+ /**
55
+ * Start a run and **wait for its result**. Outside a workflow, enqueues via the engine and blocks
56
+ * until the run settles, returning its output. Inside a running workflow, starts a **linked child**
57
+ * (`ctx.child`) — the parent suspends until the child settles — and returns the child's output.
58
+ */
59
+ static start(input, opts) {
60
+ const ctx = getCurrentWorkflowCtx();
61
+ if (ctx) {
62
+ // INSIDE: linked child. Pass opts?.runId as the childId; when absent, ctx.child derives a
63
+ // deterministic, replay-stable id from call position — never generate one here.
64
+ // biome-ignore lint/complexity/noThisInStatic: `this` is the polymorphic subclass, declared as `this: C` above — it is the dispatch mechanism. Naming the class here would always start BaseWorkflow instead of the caller's workflow.
65
+ return ctx.child(this, input, opts?.runId);
66
+ }
67
+ // OUTSIDE: enqueue on the engine, then block until the run reaches a TERMINAL state. `runId` is a
68
+ // BaseWorkflow-only option (not part of StartOptions) — strip it before forwarding to engine.start.
69
+ return (async () => {
70
+ const engine = await resolveEngine();
71
+ const { runId: _runId, ...startOpts } = opts ?? {};
72
+ const runId = opts?.runId ?? globalThis.crypto.randomUUID();
73
+ // biome-ignore lint/complexity/noThisInStatic: see .start's child branch — `this` is the polymorphic subclass (`this: C`), not BaseWorkflow.
74
+ await engine.start(this, input, runId, startOpts);
75
+ // `terminal: true` so a workflow that suspends (sleep/waitForSignal/waitForEvent/async step)
76
+ // keeps blocking through the suspension and returns the real output — the ".start = I want the
77
+ // result" contract, matching the INSIDE ctx.child path (which also waits for terminal).
78
+ const result = await engine.waitForRun(runId, { terminal: true });
79
+ return result.output;
80
+ })();
81
+ }
82
+ /**
83
+ * Start a run **fire-and-forget** and return its `{ runId }` without waiting. Outside a workflow,
84
+ * enqueues via the engine and returns immediately. Inside a running workflow, kicks off a
85
+ * fire-and-forget child (`ctx.startChild`) — the parent keeps running — and returns the child id.
86
+ */
87
+ static dispatch(input, opts) {
88
+ const ctx = getCurrentWorkflowCtx();
89
+ if (ctx) {
90
+ // INSIDE: fire-and-forget child. Same childId rule as .start — let ctx derive it when absent.
91
+ // biome-ignore lint/complexity/noThisInStatic: see .start — `this` is the polymorphic subclass (`this: C`), not BaseWorkflow.
92
+ return ctx.startChild(this, input, opts?.runId).then((runId) => ({ runId }));
93
+ }
94
+ // OUTSIDE: enqueue and return the id without blocking on the settle. `runId` is a BaseWorkflow-only
95
+ // option (not part of StartOptions) — strip it before forwarding to engine.start.
96
+ return (async () => {
97
+ const engine = await resolveEngine();
98
+ const { runId: _runId, ...startOpts } = opts ?? {};
99
+ const runId = opts?.runId ?? globalThis.crypto.randomUUID();
100
+ // biome-ignore lint/complexity/noThisInStatic: see .start — `this` is the polymorphic subclass (`this: C`), not BaseWorkflow.
101
+ await engine.start(this, input, runId, startOpts);
102
+ return { runId };
103
+ })();
104
+ }
105
+ }
106
+ //# sourceMappingURL=base-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-workflow.js","sourceRoot":"","sources":["../../src/base-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA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token: string): Promise<SignalWaiter | null>;
50
50
  listSignalWaiters(prefix: string): Promise<SignalWaiter[]>;
51
+ removeSignalWaiter(waiter: SignalWaiter): Promise<void>;
51
52
  bufferSignal(token: string, payload: unknown): Promise<void>;
52
53
  takeBufferedSignal(token: string): Promise<{
53
54
  payload: unknown;
54
55
  } | null>;
56
+ bufferEvent(input: {
57
+ name: string;
58
+ payload: unknown;
59
+ id: string;
60
+ publishedAt: number;
61
+ }): Promise<void>;
62
+ listBufferedEvents(name: string, limit: number): Promise<Array<{
63
+ id: string;
64
+ payload: unknown;
65
+ publishedAt: number;
66
+ }>>;
67
+ removeBufferedEvent(id: string): Promise<boolean>;
55
68
  listRuns(query: RunQuery): Promise<WorkflowRun[]>;
56
69
  listCheckpoints(runId: string): Promise<StepCheckpoint[]>;
57
70
  getLatestCheckpointByName(runId: string, name: string): Promise<StepCheckpoint | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"codec-state-store.d.ts","sourceRoot":"","sources":["../../src/codec-state-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,cAAc,EACd,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAChC,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;CACjC;AAED;;;;;;;;;GASG;AACH,qBAAa,eAAgB,YAAW,UAAU;IAE9C,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK;gBADL,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,YAAY;IAGtC,OAAO,CAAC,GAAG;IAGX,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,MAAM;IAGd,OAAO,CAAC,MAAM;IAGd,OAAO,CAAC,KAAK;IAGb,OAAO,CAAC,KAAK;IAIb,YAAY,I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AAE,MAAM,GACZ,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAIxE,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAG3C,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAGjD,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAGzD,yBAAyB,CAC7B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAWhC,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;CAQhG"}
@@ -93,6 +93,9 @@ export class CodecStateStore {
93
93
  listSignalWaiters(prefix) {
94
94
  return this.inner.listSignalWaiters(prefix);
95
95
  }
96
+ removeSignalWaiter(waiter) {
97
+ return this.inner.removeSignalWaiter(waiter);
98
+ }
96
99
  bufferSignal(token, payload) {
97
100
  return this.inner.bufferSignal(token, this.enc(payload));
98
101
  }
@@ -100,6 +103,16 @@ export class CodecStateStore {
100
103
  const buffered = await this.inner.takeBufferedSignal(token);
101
104
  return buffered && { payload: this.dec(buffered.payload) };
102
105
  }
106
+ bufferEvent(input) {
107
+ return this.inner.bufferEvent({ ...input, payload: this.enc(input.payload) });
108
+ }
109
+ async listBufferedEvents(name, limit) {
110
+ const events = await this.inner.listBufferedEvents(name, limit);
111
+ return events.map((e) => ({ ...e, payload: this.dec(e.payload) }));
112
+ }
113
+ removeBufferedEvent(id) {
114
+ return this.inner.removeBufferedEvent(id);
115
+ }
103
116
  async listRuns(query) {
104
117
  return (await this.inner.listRuns(query)).map((r) => this.decRun(r));
105
118
  }
@@ -1 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kB;QACjE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,2BAA2B;YACpD,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,KAAK,EAAE,QAAQ,CAAC;YAC/D,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CACtD,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAC5C,CAAC;QACN,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;CACF"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Cross-package, cross-runtime marker for engine CONTROL-FLOW signals — {@link WorkflowSuspended}
3
+ * and {@link ContinueAsNew} (see `./errors.ts`). These are thrown by `WorkflowCtx` ops to unwind the
4
+ * current turn — never real failures — so a workflow's `catch` block MUST rethrow them untouched.
5
+ * Running a failure/cleanup path on a control-flow signal corrupts the run: it emits extra
6
+ * `recordStep` commands into history that a subsequent replay didn't produce the first time,
7
+ * surfacing as a `NonDeterminismError` on resume.
8
+ *
9
+ * `Symbol.for` (the GLOBAL registry), NOT a plain `Symbol()` — so a duplicate copy of this module
10
+ * (pnpm peer-dependency multiplexing, or a dual ESM/CJS load) still collapses onto the SAME symbol.
11
+ * Same rationale as `DURABLE_STEP_NAME` in `./step-name-symbol.ts`; uses the `@agora/` wire namespace
12
+ * matching the other cross-package symbols in this package.
13
+ *
14
+ * Deliberately checked as a stamped property, NOT `instanceof` — `instanceof` only recognizes a
15
+ * signal thrown by the SAME class the checking code imported, which fails across a duplicate module
16
+ * copy (two different `WorkflowSuspended`/`ContinueAsNew` classes for what is, from a workflow
17
+ * author's catch block, the same "this isn't a real error, let it through" event).
18
+ *
19
+ * NOT designed to survive a serialization boundary (e.g. JSON over the wire) — these signals are
20
+ * always thrown and caught in-process within a single replay turn, never (de)serialized, so a
21
+ * stamped-but-not-cloneable property is sufficient.
22
+ */
23
+ export declare const CONTROL_FLOW_SIGNAL: unique symbol;
24
+ /**
25
+ * True for any engine control-flow signal (currently: {@link WorkflowSuspended} and
26
+ * {@link ContinueAsNew}) — regardless of which module instance threw it. Workflow `catch` blocks
27
+ * MUST rethrow these untouched; running a failure/cleanup path on one corrupts the run's history
28
+ * (extra commands recorded during what replay will later see as a suspend, not a failure) and the
29
+ * resumed replay dies with a non-determinism error.
30
+ *
31
+ * Deliberately NOT control-flow (do not add to this predicate):
32
+ * - a cancelled run — a TERMINAL outcome the consumer may legitimately want to observe and react to
33
+ * (e.g. release a lock), not a mid-turn unwind to rethrow untouched.
34
+ * - a `FatalError` / an awaited step rejection reaching the engine — a REAL failure a workflow's
35
+ * `catch` is meant to compensate for; misclassifying it as control-flow would swallow genuine
36
+ * errors instead of protecting them.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * try {
41
+ * await ctx.step('chargeCard', input);
42
+ * } catch (error) {
43
+ * if (isWorkflowControlFlowSignal(error)) throw error; // suspend/continue-as-new: rethrow as-is
44
+ * await ctx.step('refund', input); // a REAL failure — safe to run cleanup here
45
+ * throw error;
46
+ * }
47
+ * ```
48
+ */
49
+ export declare function isWorkflowControlFlowSignal(error: unknown): boolean;
50
+ //# sourceMappingURL=control-flow-signal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-flow-signal.d.ts","sourceRoot":"","sources":["../../src/control-flow-signal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,MAAkD,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAMnE"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Cross-package, cross-runtime marker for engine CONTROL-FLOW signals — {@link WorkflowSuspended}
3
+ * and {@link ContinueAsNew} (see `./errors.ts`). These are thrown by `WorkflowCtx` ops to unwind the
4
+ * current turn — never real failures — so a workflow's `catch` block MUST rethrow them untouched.
5
+ * Running a failure/cleanup path on a control-flow signal corrupts the run: it emits extra
6
+ * `recordStep` commands into history that a subsequent replay didn't produce the first time,
7
+ * surfacing as a `NonDeterminismError` on resume.
8
+ *
9
+ * `Symbol.for` (the GLOBAL registry), NOT a plain `Symbol()` — so a duplicate copy of this module
10
+ * (pnpm peer-dependency multiplexing, or a dual ESM/CJS load) still collapses onto the SAME symbol.
11
+ * Same rationale as `DURABLE_STEP_NAME` in `./step-name-symbol.ts`; uses the `@agora/` wire namespace
12
+ * matching the other cross-package symbols in this package.
13
+ *
14
+ * Deliberately checked as a stamped property, NOT `instanceof` — `instanceof` only recognizes a
15
+ * signal thrown by the SAME class the checking code imported, which fails across a duplicate module
16
+ * copy (two different `WorkflowSuspended`/`ContinueAsNew` classes for what is, from a workflow
17
+ * author's catch block, the same "this isn't a real error, let it through" event).
18
+ *
19
+ * NOT designed to survive a serialization boundary (e.g. JSON over the wire) — these signals are
20
+ * always thrown and caught in-process within a single replay turn, never (de)serialized, so a
21
+ * stamped-but-not-cloneable property is sufficient.
22
+ */
23
+ export const CONTROL_FLOW_SIGNAL = Symbol.for('@agora/durable:control-flow');
24
+ /**
25
+ * True for any engine control-flow signal (currently: {@link WorkflowSuspended} and
26
+ * {@link ContinueAsNew}) — regardless of which module instance threw it. Workflow `catch` blocks
27
+ * MUST rethrow these untouched; running a failure/cleanup path on one corrupts the run's history
28
+ * (extra commands recorded during what replay will later see as a suspend, not a failure) and the
29
+ * resumed replay dies with a non-determinism error.
30
+ *
31
+ * Deliberately NOT control-flow (do not add to this predicate):
32
+ * - a cancelled run — a TERMINAL outcome the consumer may legitimately want to observe and react to
33
+ * (e.g. release a lock), not a mid-turn unwind to rethrow untouched.
34
+ * - a `FatalError` / an awaited step rejection reaching the engine — a REAL failure a workflow's
35
+ * `catch` is meant to compensate for; misclassifying it as control-flow would swallow genuine
36
+ * errors instead of protecting them.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * try {
41
+ * await ctx.step('chargeCard', input);
42
+ * } catch (error) {
43
+ * if (isWorkflowControlFlowSignal(error)) throw error; // suspend/continue-as-new: rethrow as-is
44
+ * await ctx.step('refund', input); // a REAL failure — safe to run cleanup here
45
+ * throw error;
46
+ * }
47
+ * ```
48
+ */
49
+ export function isWorkflowControlFlowSignal(error) {
50
+ return (typeof error === 'object' &&
51
+ error !== null &&
52
+ error[CONTROL_FLOW_SIGNAL] === true);
53
+ }
54
+ //# sourceMappingURL=control-flow-signal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"control-flow-signal.js","sourceRoot":"","sources":["../../src/control-flow-signal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAkB,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAE5F;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAc;IACxD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACb,KAA6C,CAAC,mBAAmB,CAAC,KAAK,IAAI,CAC7E,CAAC;AACJ,CAAC"}
@@ -21,12 +21,22 @@ export interface RedisPubSub {
21
21
  * the `@adonisjs/redis` connection takes a channel + a per-message handler.
22
22
  */
23
23
  subscribe(channel: string, handler?: (message: string, channel: string) => void): unknown;
24
- /** ioredis-only: per-message event used when a dedicated subscriber connection is duplicated. */
25
- on?(event: 'message', listener: (channel: string, message: string) => void): unknown;
24
+ /**
25
+ * ioredis-only: connection events. `message` delivers a payload on a duplicated subscriber;
26
+ * `error`/`ready`/`subscribe` are used by the watchdog (see {@link RedisControlPlaneOptions.pingIntervalMs}).
27
+ */
28
+ on?(event: string, listener: (...args: never[]) => void): unknown;
26
29
  /** ioredis-only: build a dedicated subscriber connection (pub/sub can't share a command client). */
27
30
  duplicate?(): RedisPubSub;
28
- /** ioredis-only: tear down the duplicated subscriber connection. */
29
- disconnect?(): void;
31
+ /**
32
+ * ioredis-only: tear down the duplicated subscriber connection. `disconnect(true)` reconnects
33
+ * (ioredis's `retryStrategy` + `autoResubscribe`) rather than closing for good.
34
+ */
35
+ disconnect?(reconnect?: boolean): void;
36
+ /** ioredis-only: liveness probe. Legal in subscriber mode (ioredis's `VALID_IN_SUBSCRIBER_MODE`). */
37
+ ping?(): Promise<unknown>;
38
+ /** ioredis-only: connection state — the watchdog skips anything that isn't `'ready'`. */
39
+ status?: string;
30
40
  }
31
41
  export interface RedisControlPlaneOptions {
32
42
  /** An ioredis instance or an `@adonisjs/redis` connection used for pub/sub. */
@@ -37,6 +47,22 @@ export interface RedisControlPlaneOptions {
37
47
  * and a NestJS fleet sharing one Redis interoperate on the same control plane.
38
48
  */
39
49
  prefix?: string;
50
+ /**
51
+ * How often (ms) to PING the duplicated pub/sub subscriber connection to detect — and recover
52
+ * from — a silent connection loss. A subscriber connection never WRITEs on its own (it only
53
+ * receives PUBLISHed messages), so when a VPN/NAT/idle-timeout drops the underlying TCP
54
+ * connection, ioredis has nothing that would surface the loss: no write ever fails, no timeout
55
+ * ever fires, and the connection sits "subscribed" forever while the server's `PUBSUB NUMSUB`
56
+ * already shows 0 — cross-pod cancels and lifecycle events silently stop arriving until the
57
+ * process restarts. A PING rejection or timeout means the connection is dead, so we
58
+ * `disconnect(true)` it: ioredis's `retryStrategy` reconnects and `autoResubscribe` (default
59
+ * `true`) restores the channel automatically.
60
+ *
61
+ * Pass `0` or `false` to disable (e.g. a short-lived test where the interval would outlive it).
62
+ * Defaults to `30_000`. Only applies to the raw-ioredis path — an `@adonisjs/redis` connection
63
+ * manages its own subscriber connection and its own health.
64
+ */
65
+ pingIntervalMs?: number | false;
40
66
  }
41
67
  /**
42
68
  * A {@link ControlPlane} backed by Redis pub/sub: the cross-pod broadcast channel for workflow
@@ -55,10 +81,36 @@ export declare class RedisControlPlane implements ControlPlane {
55
81
  private readonly channel;
56
82
  private subscriber;
57
83
  private subscribed;
84
+ private readonly pingIntervalMs;
85
+ private pingWatchdogTimer;
86
+ private closed;
58
87
  constructor(options: RedisControlPlaneOptions);
59
88
  publishControl(msg: ControlMessage): Promise<void>;
60
89
  onControl(handler: (msg: ControlMessage) => void): void;
61
- /** Tear down the dedicated subscriber connection, if one was duplicated (ioredis path). */
90
+ /**
91
+ * Attach a de-duplicated `error` listener to the duplicated subscriber and start the ping
92
+ * watchdog. The `error` listener is not optional hygiene: an unhandled `error` event on an
93
+ * ioredis instance crashes the process in some setups, and a dead/reconnecting subscriber emits
94
+ * them in bursts — so this connection, which nothing else listens to, would take the app down.
95
+ */
96
+ private trackSubscriber;
97
+ /**
98
+ * Start the watchdog interval, unless it's disabled or already running (idempotent). Unref'd so
99
+ * it never keeps the process alive on its own; cleared in {@link close}.
100
+ */
101
+ private startPingWatchdog;
102
+ /**
103
+ * PING the subscriber; on rejection or timeout, `disconnect(true)` so ioredis's `retryStrategy`
104
+ * reconnects and `autoResubscribe` restores the channel. Skips a connection that isn't `'ready'`
105
+ * — it's already mid-(re)connect, so a fresh ping would just race that cycle.
106
+ *
107
+ * The timeout is capped at `pingIntervalMs` itself (never above `SUBSCRIBER_PING_TIMEOUT_MS`):
108
+ * waiting longer than the gap between checks to declare one dead would just mean two checks race
109
+ * each other, and it lets a short interval shrink the whole detect → reconnect cycle instead of
110
+ * always eating the full multi-second default.
111
+ */
112
+ private pingSubscriber;
113
+ /** Stop the watchdog and tear down the dedicated subscriber connection (ioredis path). */
62
114
  close(): Promise<void>;
63
115
  }
64
116
  //# sourceMappingURL=redis-control-plane.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"redis-control-plane.d.ts","sourceRoot":"","sources":["../../../src/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I7B"}
1
+ {"version":3,"file":"redis-control-plane.d.ts","sourceRoot":"","sources":["../../../src/control-plane-redis/redis-control-plane.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACnD;;;OAGG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC;IAC1F;;;OAGG;IACH,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC;IAClE,oGAAoG;IACpG,SAAS,CAAC,IAAI,WAAW,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,qGAAqG;IACrG,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,+EAA+E;IAC/E,UAAU,EAAE,WAAW,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CACjC;AAiBD;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IACpD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAc;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,UAAU,CAA0B;IAC5C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,iBAAiB,CAA6C;IACtE,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,wBAAwB;IAMvC,cAAc,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,GAAG,IAAI;IA2BvD;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAavB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;;;;;;;OASG;YACW,cAAc;IAgC5B,0FAA0F;IACpF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
@@ -1,3 +1,18 @@
1
+ /** Default {@link RedisControlPlaneOptions.pingIntervalMs}. */
2
+ const DEFAULT_PING_INTERVAL_MS = 30_000;
3
+ /** How long a single watchdog PING may take before its subscriber is presumed dead. */
4
+ const SUBSCRIBER_PING_TIMEOUT_MS = 5_000;
5
+ /**
6
+ * Normalise `pingIntervalMs`: `undefined` → the default, `0`/`false` → disabled, any other number
7
+ * → itself verbatim (including a caller's smaller interval for short-lived tests).
8
+ */
9
+ function normalizePingInterval(value) {
10
+ if (value === undefined)
11
+ return DEFAULT_PING_INTERVAL_MS;
12
+ if (value === false || value === 0)
13
+ return false;
14
+ return value;
15
+ }
1
16
  /**
2
17
  * A {@link ControlPlane} backed by Redis pub/sub: the cross-pod broadcast channel for workflow
3
18
  * **lifecycle events** (so a dashboard-only pod can live-tail a run executing on a worker pod) and
@@ -15,9 +30,13 @@ export class RedisControlPlane {
15
30
  channel;
16
31
  subscriber;
17
32
  subscribed = false;
33
+ pingIntervalMs;
34
+ pingWatchdogTimer;
35
+ closed = false;
18
36
  constructor(options) {
19
37
  this.connection = options.connection;
20
38
  this.channel = `${options.prefix ?? 'durable'}-control`;
39
+ this.pingIntervalMs = normalizePingInterval(options.pingIntervalMs);
21
40
  }
22
41
  async publishControl(msg) {
23
42
  await this.connection.publish(this.channel, JSON.stringify(msg));
@@ -41,15 +60,94 @@ export class RedisControlPlane {
41
60
  const sub = this.connection.duplicate();
42
61
  this.subscriber = sub;
43
62
  void sub.subscribe(this.channel);
44
- sub.on?.('message', (_channel, payload) => deliver(payload));
63
+ sub.on?.('message', ((_channel, payload) => deliver(payload)));
64
+ this.trackSubscriber(sub);
45
65
  }
46
66
  else {
47
67
  // `@adonisjs/redis` connection: manages its own subscriber connection; handler gets the message.
48
68
  void this.connection.subscribe(this.channel, (payload) => deliver(payload));
49
69
  }
50
70
  }
51
- /** Tear down the dedicated subscriber connection, if one was duplicated (ioredis path). */
71
+ /**
72
+ * Attach a de-duplicated `error` listener to the duplicated subscriber and start the ping
73
+ * watchdog. The `error` listener is not optional hygiene: an unhandled `error` event on an
74
+ * ioredis instance crashes the process in some setups, and a dead/reconnecting subscriber emits
75
+ * them in bursts — so this connection, which nothing else listens to, would take the app down.
76
+ */
77
+ trackSubscriber(sub) {
78
+ let loggedSinceReady = false;
79
+ sub.on?.('error', ((err) => {
80
+ if (loggedSinceReady)
81
+ return; // one line per reconnect burst, not one per retry
82
+ loggedSinceReady = true;
83
+ console.warn(`[adonis-durable] control-plane subscriber error: ${err.message}`);
84
+ }));
85
+ sub.on?.('ready', (() => {
86
+ loggedSinceReady = false;
87
+ }));
88
+ this.startPingWatchdog(sub);
89
+ }
90
+ /**
91
+ * Start the watchdog interval, unless it's disabled or already running (idempotent). Unref'd so
92
+ * it never keeps the process alive on its own; cleared in {@link close}.
93
+ */
94
+ startPingWatchdog(sub) {
95
+ if (this.pingWatchdogTimer || this.pingIntervalMs === false)
96
+ return;
97
+ if (typeof sub.ping !== 'function')
98
+ return; // not an ioredis-shaped connection — nothing to probe
99
+ this.pingWatchdogTimer = setInterval(() => {
100
+ void this.pingSubscriber(sub);
101
+ }, this.pingIntervalMs);
102
+ this.pingWatchdogTimer.unref?.();
103
+ }
104
+ /**
105
+ * PING the subscriber; on rejection or timeout, `disconnect(true)` so ioredis's `retryStrategy`
106
+ * reconnects and `autoResubscribe` restores the channel. Skips a connection that isn't `'ready'`
107
+ * — it's already mid-(re)connect, so a fresh ping would just race that cycle.
108
+ *
109
+ * The timeout is capped at `pingIntervalMs` itself (never above `SUBSCRIBER_PING_TIMEOUT_MS`):
110
+ * waiting longer than the gap between checks to declare one dead would just mean two checks race
111
+ * each other, and it lets a short interval shrink the whole detect → reconnect cycle instead of
112
+ * always eating the full multi-second default.
113
+ */
114
+ async pingSubscriber(sub) {
115
+ if (sub.status !== undefined && sub.status !== 'ready')
116
+ return;
117
+ const timeoutMs = this.pingIntervalMs === false
118
+ ? SUBSCRIBER_PING_TIMEOUT_MS
119
+ : Math.min(SUBSCRIBER_PING_TIMEOUT_MS, this.pingIntervalMs);
120
+ try {
121
+ await new Promise((resolve, reject) => {
122
+ const timer = setTimeout(() => reject(new Error('ping timed out')), timeoutMs);
123
+ sub
124
+ .ping?.()
125
+ .then(() => {
126
+ clearTimeout(timer);
127
+ resolve();
128
+ })
129
+ .catch((err) => {
130
+ clearTimeout(timer);
131
+ reject(err instanceof Error ? err : new Error(String(err)));
132
+ });
133
+ });
134
+ }
135
+ catch (err) {
136
+ // A ping in flight when close() lands would otherwise RESURRECT the connection we just tore
137
+ // down: disconnect(true) reconnects rather than closes. Re-check after the await.
138
+ if (this.closed)
139
+ return;
140
+ const message = err instanceof Error ? err.message : String(err);
141
+ console.warn(`[adonis-durable] control-plane subscriber unresponsive (${message}) — reconnecting to restore its subscription`);
142
+ sub.disconnect?.(true);
143
+ }
144
+ }
145
+ /** Stop the watchdog and tear down the dedicated subscriber connection (ioredis path). */
52
146
  async close() {
147
+ this.closed = true;
148
+ if (this.pingWatchdogTimer)
149
+ clearInterval(this.pingWatchdogTimer);
150
+ this.pingWatchdogTimer = undefined;
53
151
  this.subscriber?.disconnect?.();
54
152
  this.subscriber = undefined;
55
153
  }