@bitfab/sdk 0.61.6 → 0.62.1

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
@@ -42,7 +42,7 @@ var __version__, __packageName__;
42
42
  var init_version_generated = __esm({
43
43
  "src/version.generated.ts"() {
44
44
  "use strict";
45
- __version__ = "0.61.6";
45
+ __version__ = "0.62.1";
46
46
  __packageName__ = "@bitfab/sdk";
47
47
  }
48
48
  });
@@ -3697,12 +3697,13 @@ function installReplayInterruptHandlers(target) {
3697
3697
  const removeHandlers = () => {
3698
3698
  for (const [signal, handler] of handlers) {
3699
3699
  host.removeListener(signal, handler);
3700
+ replayListeners.delete(handler);
3700
3701
  }
3701
3702
  handlers.clear();
3702
3703
  };
3703
3704
  let interrupting = false;
3704
3705
  const handleSignal = async (signal) => {
3705
- const hostHandlesSignal = host.listenerCount(signal) > 1;
3706
+ const hostHandlesSignal = host.listeners(signal).some((listener) => !replayListeners.has(listener));
3706
3707
  const markedInterrupted = await target.interrupt();
3707
3708
  removeHandlers();
3708
3709
  if (target.onInterrupt !== void 0) {
@@ -3731,11 +3732,12 @@ function installReplayInterruptHandlers(target) {
3731
3732
  void handleSignal(signal);
3732
3733
  };
3733
3734
  handlers.set(signal, handler);
3735
+ replayListeners.add(handler);
3734
3736
  host.on(signal, handler);
3735
3737
  }
3736
3738
  return { remove: removeHandlers, interrupted: () => interrupting };
3737
3739
  }
3738
- var REPLAY_INTERRUPT_SIGNALS;
3740
+ var REPLAY_INTERRUPT_SIGNALS, replayListeners;
3739
3741
  var init_replayInterrupt = __esm({
3740
3742
  "src/replayInterrupt.ts"() {
3741
3743
  "use strict";
@@ -3743,6 +3745,7 @@ var init_replayInterrupt = __esm({
3743
3745
  "SIGINT",
3744
3746
  "SIGTERM"
3745
3747
  ];
3748
+ replayListeners = /* @__PURE__ */ new Set();
3746
3749
  }
3747
3750
  });
3748
3751
 
@@ -4127,8 +4130,6 @@ function carriedOverReplayItem(finished) {
4127
4130
  model: null,
4128
4131
  dbSnapshotRef: null,
4129
4132
  dbBranchTimings: null,
4130
- traceOutline: null,
4131
- originalTraceOutline: null,
4132
4133
  carriedOver: true
4133
4134
  };
4134
4135
  }
@@ -4421,9 +4422,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4421
4422
  tokens: null,
4422
4423
  model: serverItem.originalModel ?? serverItem.model ?? null,
4423
4424
  dbSnapshotRef: dbSnapshotRef ?? null,
4424
- dbBranchTimings: dbBranchTimings ?? null,
4425
- traceOutline: null,
4426
- originalTraceOutline: null
4425
+ dbBranchTimings: dbBranchTimings ?? null
4427
4426
  };
4428
4427
  }
4429
4428
  try {
@@ -4511,9 +4510,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4511
4510
  tokens: null,
4512
4511
  model: originalModel,
4513
4512
  dbSnapshotRef: dbSnapshotRef ?? null,
4514
- dbBranchTimings: dbBranchTimings ?? null,
4515
- traceOutline: null,
4516
- originalTraceOutline: null
4513
+ dbBranchTimings: dbBranchTimings ?? null
4517
4514
  };
4518
4515
  }
4519
4516
  async function waitForReplayPersistence(httpClient, experimentId, replayedTraceIds) {
@@ -4580,11 +4577,11 @@ function sleepForReplayPersistence(ms) {
4580
4577
  setTimeout(resolve, ms);
4581
4578
  });
4582
4579
  }
4583
- async function mapWithConcurrency2(tasks, maxConcurrency, onSettled, onStarted) {
4580
+ async function mapWithConcurrency2(tasks, maxConcurrency, onSettled, onStarted, shouldStop) {
4584
4581
  const results = new Array(tasks.length);
4585
4582
  let nextIndex = 0;
4586
4583
  async function worker() {
4587
- while (nextIndex < tasks.length) {
4584
+ while (nextIndex < tasks.length && shouldStop?.() !== true) {
4588
4585
  const index = nextIndex++;
4589
4586
  onStarted?.(index);
4590
4587
  const result = await tasks[index]();
@@ -4597,7 +4594,7 @@ async function mapWithConcurrency2(tasks, maxConcurrency, onSettled, onStarted)
4597
4594
  () => worker()
4598
4595
  );
4599
4596
  await Promise.all(workers);
4600
- return results;
4597
+ return results.slice(0, nextIndex);
4601
4598
  }
4602
4599
  async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, registeredOverrides = []) {
4603
4600
  if (options?.resume !== void 0) {
@@ -4881,9 +4878,7 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
4881
4878
  tokens: item.tokens,
4882
4879
  model: item.model,
4883
4880
  dbSnapshotRef: item.dbSnapshotRef,
4884
- dbBranchTimings: item.dbBranchTimings,
4885
- traceOutline: item.traceOutline,
4886
- originalTraceOutline: item.originalTraceOutline
4881
+ dbBranchTimings: item.dbBranchTimings
4887
4882
  }
4888
4883
  });
4889
4884
  } catch {
@@ -4914,9 +4909,11 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
4914
4909
  });
4915
4910
  } catch {
4916
4911
  }
4917
- } : void 0
4912
+ } : void 0,
4913
+ interrupted
4918
4914
  );
4919
4915
  const resultItems = [...carriedOverItems, ...ranItems];
4916
+ throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
4920
4917
  if (options?.dryRun === true) {
4921
4918
  throwIfInterrupted(
4922
4919
  interrupted,
@@ -4978,9 +4975,7 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
4978
4975
  }
4979
4976
  if (mapped !== void 0) {
4980
4977
  item.tokens = replayTokens?.[mapped] ?? null;
4981
- item.traceOutline = completeResult.traceOutlines?.[mapped] ?? null;
4982
4978
  }
4983
- item.originalTraceOutline = completeResult.originalTraceOutlines?.[item.originalTraceId] ?? null;
4984
4979
  }
4985
4980
  if (completedCount > 0 && missing.length === completedCount) {
4986
4981
  const serverCount = completeResult.traceCount !== void 0 ? ` The server persisted ${completeResult.traceCount} trace(s) for this run.` : "";