@niscorp/cortex 0.1.0 → 0.1.3

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.js CHANGED
@@ -889,6 +889,7 @@ var wireRun = (wiring) => {
889
889
  if (options?.onEvent) channel.onEvent(options.onEvent);
890
890
  const approvals = createApprovalBridge();
891
891
  const controller = new AbortController();
892
+ let abortReason;
892
893
  const externalSignal = options?.signal;
893
894
  const onExternalAbort = () => controller.abort();
894
895
  if (externalSignal) {
@@ -988,6 +989,9 @@ var wireRun = (wiring) => {
988
989
  }
989
990
  };
990
991
  }
992
+ if (!outcome.ok && outcome.error.code === "aborted" && abortReason !== void 0) {
993
+ outcome = { ...outcome, error: { ...outcome.error, cause: abortReason } };
994
+ }
991
995
  channel.emit({ type: "run-end", result: outcome, meta: outcome.meta });
992
996
  channel.close();
993
997
  if (externalSignal) externalSignal.removeEventListener("abort", onExternalAbort);
@@ -1013,7 +1017,10 @@ var wireRun = (wiring) => {
1013
1017
  elapsedMs: state.elapsedBase + (Date.now() - state.startedAt),
1014
1018
  ...state.pending && { pending: state.pending }
1015
1019
  }),
1016
- abort: () => controller.abort()
1020
+ abort: (reason) => {
1021
+ if (!controller.signal.aborted) abortReason = reason;
1022
+ controller.abort();
1023
+ }
1017
1024
  };
1018
1025
  };
1019
1026
  var createRun = (definition, input, options) => wireRun({ definition, input, options, runId: newRunId() });