@lostgradient/weft 0.5.0 → 0.6.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.
@@ -19,6 +19,7 @@ export type EngineCreateRuntimeOptions = EngineConstructorOptions & {
19
19
  workflows?: Record<string, AnyWorkflowDefinition> | undefined;
20
20
  recover?: boolean | undefined;
21
21
  acknowledgeUnknownWorkflowTypes?: boolean | undefined;
22
+ startScheduler?: boolean | undefined;
22
23
  };
23
24
  export type NormalizedWorkerExecutionConfiguration = {
24
25
  mode: 'inline';
@@ -29,6 +29,20 @@ export type EngineCreateOptions<TWorkflowDefinitions extends Record<string, AnyW
29
29
  workflows?: TWorkflowDefinitions;
30
30
  /** Activity definitions to register before workflows. */
31
31
  activities?: TActivityDefinitions;
32
+ /**
33
+ * Start the scheduler's durable-timer polling loop after registration so
34
+ * `ctx.sleep(...)` and `engine.schedule(...)` timers fire in a long-lived
35
+ * in-process host. This is independent of `recover`: it controls *whether
36
+ * timers fire*, not *who drives `recoverAll`*.
37
+ *
38
+ * Defaults to `recover !== false`. A host that opts out of auto-recovery
39
+ * with `recover: false` (because it drives its own `recoverAll()` to capture
40
+ * the recovered handles) can still arm the poller by passing
41
+ * `startScheduler: true`. Pass `startScheduler: false` to keep the poller
42
+ * stopped even when recovery runs (tests / `ScopedStorage` engines that tick
43
+ * the scheduler deterministically).
44
+ */
45
+ startScheduler?: boolean;
32
46
  } & ({
33
47
  /**
34
48
  * Recover stored running workflows after registration. Defaults to
@@ -226,10 +226,10 @@ export class Engine extends EventTarget {
226
226
  engine.register(definition);
227
227
  }
228
228
  await engine.#acquireLeaseIfConfigured();
229
- if (options.recover !== !1) {
229
+ if (options.recover !== !1)
230
230
  await engine.recoverAll(options.acknowledgeUnknownWorkflowTypes !== void 0 ? { acknowledgeUnknownWorkflowTypes: options.acknowledgeUnknownWorkflowTypes } : {});
231
+ if (options.startScheduler ?? options.recover !== !1)
231
232
  getInternals(engine).scheduler.start();
232
- }
233
233
  } catch (error) {
234
234
  await engine[Symbol.asyncDispose]();
235
235
  throw error;