@axlsdk/axl 0.17.3 → 0.17.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.
package/dist/index.cjs CHANGED
@@ -7653,6 +7653,10 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
7653
7653
  * the instance so per-event onTrace handlers don't reach into
7654
7654
  * `this.config.state` on every emission. */
7655
7655
  maxEventsPerExecution;
7656
+ /** Tracks executionIds for which we've already warned about a malformed
7657
+ * `events` field — keeps the log to one line per row instead of one per
7658
+ * rebuild tick. */
7659
+ warnedMalformedExecutions = /* @__PURE__ */ new Set();
7656
7660
  constructor(config) {
7657
7661
  super();
7658
7662
  this.config = resolveConfig(config ?? {});
@@ -7946,12 +7950,31 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
7946
7950
  return result;
7947
7951
  }
7948
7952
  /** Get all execution info (running + completed + historical). */
7953
+ /** Normalize an `ExecutionInfo` loaded from a `StateStore` so the
7954
+ * `events: AxlEvent[]` type contract holds for downstream consumers
7955
+ * (Studio aggregators, REST routes, redaction). Custom or legacy stores
7956
+ * may persist rows without `events` (or with a non-array value) — without
7957
+ * this guard, a single malformed row crashes every iterator over
7958
+ * `exec.events` and takes down dependent features. Mutates the row
7959
+ * in place; logs at most one warning per `executionId`. */
7960
+ normalizeStoredExecution(exec) {
7961
+ if (!Array.isArray(exec.events)) {
7962
+ if (!this.warnedMalformedExecutions.has(exec.executionId)) {
7963
+ this.warnedMalformedExecutions.add(exec.executionId);
7964
+ console.warn(
7965
+ `[axl] StateStore returned execution ${exec.executionId} with non-array events (got ${exec.events === null ? "null" : typeof exec.events}); coercing to []`
7966
+ );
7967
+ }
7968
+ exec.events = [];
7969
+ }
7970
+ return exec;
7971
+ }
7949
7972
  async getExecutions() {
7950
7973
  if (!this.historicalExecutionsLoadPromise && this.stateStore.listExecutions) {
7951
7974
  this.historicalExecutionsLoadPromise = this.stateStore.listExecutions().then((stored) => {
7952
7975
  for (const exec of stored) {
7953
7976
  if (!this.executions.has(exec.executionId) && !this.historicalExecutions.has(exec.executionId)) {
7954
- this.historicalExecutions.set(exec.executionId, exec);
7977
+ this.historicalExecutions.set(exec.executionId, this.normalizeStoredExecution(exec));
7955
7978
  }
7956
7979
  }
7957
7980
  }).catch(() => {
@@ -8322,8 +8345,9 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
8322
8345
  if (this.stateStore.getExecution) {
8323
8346
  const stored = await this.stateStore.getExecution(executionId);
8324
8347
  if (stored) {
8325
- this.historicalExecutions.set(executionId, stored);
8326
- return stored;
8348
+ const normalized = this.normalizeStoredExecution(stored);
8349
+ this.historicalExecutions.set(executionId, normalized);
8350
+ return normalized;
8327
8351
  }
8328
8352
  }
8329
8353
  return void 0;