bitfab 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
@@ -51,7 +51,7 @@ var __version__, __packageName__;
51
51
  var init_version_generated = __esm({
52
52
  "src/version.generated.ts"() {
53
53
  "use strict";
54
- __version__ = "0.61.6";
54
+ __version__ = "0.62.1";
55
55
  __packageName__ = "bitfab";
56
56
  }
57
57
  });
@@ -3706,12 +3706,13 @@ function installReplayInterruptHandlers(target) {
3706
3706
  const removeHandlers = () => {
3707
3707
  for (const [signal, handler] of handlers) {
3708
3708
  host.removeListener(signal, handler);
3709
+ replayListeners.delete(handler);
3709
3710
  }
3710
3711
  handlers.clear();
3711
3712
  };
3712
3713
  let interrupting = false;
3713
3714
  const handleSignal = async (signal) => {
3714
- const hostHandlesSignal = host.listenerCount(signal) > 1;
3715
+ const hostHandlesSignal = host.listeners(signal).some((listener) => !replayListeners.has(listener));
3715
3716
  const markedInterrupted = await target.interrupt();
3716
3717
  removeHandlers();
3717
3718
  if (target.onInterrupt !== void 0) {
@@ -3740,11 +3741,12 @@ function installReplayInterruptHandlers(target) {
3740
3741
  void handleSignal(signal);
3741
3742
  };
3742
3743
  handlers.set(signal, handler);
3744
+ replayListeners.add(handler);
3743
3745
  host.on(signal, handler);
3744
3746
  }
3745
3747
  return { remove: removeHandlers, interrupted: () => interrupting };
3746
3748
  }
3747
- var REPLAY_INTERRUPT_SIGNALS;
3749
+ var REPLAY_INTERRUPT_SIGNALS, replayListeners;
3748
3750
  var init_replayInterrupt = __esm({
3749
3751
  "src/replayInterrupt.ts"() {
3750
3752
  "use strict";
@@ -3752,6 +3754,7 @@ var init_replayInterrupt = __esm({
3752
3754
  "SIGINT",
3753
3755
  "SIGTERM"
3754
3756
  ];
3757
+ replayListeners = /* @__PURE__ */ new Set();
3755
3758
  }
3756
3759
  });
3757
3760
 
@@ -4136,8 +4139,6 @@ function carriedOverReplayItem(finished) {
4136
4139
  model: null,
4137
4140
  dbSnapshotRef: null,
4138
4141
  dbBranchTimings: null,
4139
- traceOutline: null,
4140
- originalTraceOutline: null,
4141
4142
  carriedOver: true
4142
4143
  };
4143
4144
  }
@@ -4430,9 +4431,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4430
4431
  tokens: null,
4431
4432
  model: serverItem.originalModel ?? serverItem.model ?? null,
4432
4433
  dbSnapshotRef: dbSnapshotRef ?? null,
4433
- dbBranchTimings: dbBranchTimings ?? null,
4434
- traceOutline: null,
4435
- originalTraceOutline: null
4434
+ dbBranchTimings: dbBranchTimings ?? null
4436
4435
  };
4437
4436
  }
4438
4437
  try {
@@ -4520,9 +4519,7 @@ async function processItem(httpClient, serverItem, fn, experimentId, mockStrateg
4520
4519
  tokens: null,
4521
4520
  model: originalModel,
4522
4521
  dbSnapshotRef: dbSnapshotRef ?? null,
4523
- dbBranchTimings: dbBranchTimings ?? null,
4524
- traceOutline: null,
4525
- originalTraceOutline: null
4522
+ dbBranchTimings: dbBranchTimings ?? null
4526
4523
  };
4527
4524
  }
4528
4525
  async function waitForReplayPersistence(httpClient, experimentId, replayedTraceIds) {
@@ -4589,11 +4586,11 @@ function sleepForReplayPersistence(ms) {
4589
4586
  setTimeout(resolve, ms);
4590
4587
  });
4591
4588
  }
4592
- async function mapWithConcurrency2(tasks, maxConcurrency, onSettled, onStarted) {
4589
+ async function mapWithConcurrency2(tasks, maxConcurrency, onSettled, onStarted, shouldStop) {
4593
4590
  const results = new Array(tasks.length);
4594
4591
  let nextIndex = 0;
4595
4592
  async function worker() {
4596
- while (nextIndex < tasks.length) {
4593
+ while (nextIndex < tasks.length && shouldStop?.() !== true) {
4597
4594
  const index = nextIndex++;
4598
4595
  onStarted?.(index);
4599
4596
  const result = await tasks[index]();
@@ -4606,7 +4603,7 @@ async function mapWithConcurrency2(tasks, maxConcurrency, onSettled, onStarted)
4606
4603
  () => worker()
4607
4604
  );
4608
4605
  await Promise.all(workers);
4609
- return results;
4606
+ return results.slice(0, nextIndex);
4610
4607
  }
4611
4608
  async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, registeredOverrides = []) {
4612
4609
  if (options?.resume !== void 0) {
@@ -4890,9 +4887,7 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
4890
4887
  tokens: item.tokens,
4891
4888
  model: item.model,
4892
4889
  dbSnapshotRef: item.dbSnapshotRef,
4893
- dbBranchTimings: item.dbBranchTimings,
4894
- traceOutline: item.traceOutline,
4895
- originalTraceOutline: item.originalTraceOutline
4890
+ dbBranchTimings: item.dbBranchTimings
4896
4891
  }
4897
4892
  });
4898
4893
  } catch {
@@ -4923,9 +4918,11 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
4923
4918
  });
4924
4919
  } catch {
4925
4920
  }
4926
- } : void 0
4921
+ } : void 0,
4922
+ interrupted
4927
4923
  );
4928
4924
  const resultItems = [...carriedOverItems, ...ranItems];
4925
+ throwIfInterrupted(interrupted, resultItems, experimentId, fullExperimentUrl);
4929
4926
  if (options?.dryRun === true) {
4930
4927
  throwIfInterrupted(
4931
4928
  interrupted,
@@ -4987,9 +4984,7 @@ async function runReplaySession(httpClient, fn, session, fullExperimentUrl, maxC
4987
4984
  }
4988
4985
  if (mapped !== void 0) {
4989
4986
  item.tokens = replayTokens?.[mapped] ?? null;
4990
- item.traceOutline = completeResult.traceOutlines?.[mapped] ?? null;
4991
4987
  }
4992
- item.originalTraceOutline = completeResult.originalTraceOutlines?.[item.originalTraceId] ?? null;
4993
4988
  }
4994
4989
  if (completedCount > 0 && missing.length === completedCount) {
4995
4990
  const serverCount = completeResult.traceCount !== void 0 ? ` The server persisted ${completeResult.traceCount} trace(s) for this run.` : "";