bitfab 0.28.5 → 0.28.7

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
@@ -624,11 +624,35 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options) {
624
624
  }
625
625
  }
626
626
  }
627
- return {
627
+ const replayResult = {
628
628
  items: resultItems,
629
629
  testRunId,
630
630
  testRunUrl: `${serviceUrl}${testRunUrl}`
631
631
  };
632
+ await writeReplayResultFile(replayResult);
633
+ return replayResult;
634
+ }
635
+ async function writeReplayResultFile(result) {
636
+ const resultPath = typeof process !== "undefined" ? process.env?.BITFAB_REPLAY_RESULT_PATH : void 0;
637
+ if (!resultPath) {
638
+ return;
639
+ }
640
+ try {
641
+ const [{ dirname }, { mkdir, writeFile }] = await Promise.all([
642
+ import("path"),
643
+ import("fs/promises")
644
+ ]);
645
+ await mkdir(dirname(resultPath), { recursive: true });
646
+ await writeFile(resultPath, `${JSON.stringify(result, null, 2)}
647
+ `);
648
+ } catch (err) {
649
+ try {
650
+ console.warn(
651
+ `Bitfab: failed to write replay result to BITFAB_REPLAY_RESULT_PATH (${resultPath}): ${err instanceof Error ? err.message : String(err)}`
652
+ );
653
+ } catch {
654
+ }
655
+ }
632
656
  }
633
657
  var BITFAB_PROGRESS_PREFIX;
634
658
  var init_replay = __esm({
@@ -668,7 +692,7 @@ __export(index_exports, {
668
692
  module.exports = __toCommonJS(index_exports);
669
693
 
670
694
  // src/version.generated.ts
671
- var __version__ = "0.28.5";
695
+ var __version__ = "0.28.7";
672
696
 
673
697
  // src/constants.ts
674
698
  var DEFAULT_SERVICE_URL = "https://bitfab.ai";
@@ -3319,6 +3343,8 @@ var noOpTrace = {
3319
3343
  setMetadata() {
3320
3344
  },
3321
3345
  addContext() {
3346
+ },
3347
+ drop() {
3322
3348
  }
3323
3349
  };
3324
3350
  function getCurrentSpan() {
@@ -3395,6 +3421,12 @@ function getCurrentTrace() {
3395
3421
  traceState.contexts.push(context);
3396
3422
  } catch {
3397
3423
  }
3424
+ },
3425
+ drop() {
3426
+ try {
3427
+ getOrCreateTraceState().dropped = true;
3428
+ } catch {
3429
+ }
3398
3430
  }
3399
3431
  };
3400
3432
  }
@@ -3984,6 +4016,7 @@ var Bitfab = class {
3984
4016
  testRunId: traceState?.testRunId,
3985
4017
  inputSourceTraceId: traceState?.inputSourceTraceId,
3986
4018
  dbSnapshotRef: traceState?.dbSnapshotRef,
4019
+ dropped: traceState?.dropped,
3987
4020
  // Built AFTER the wrapped fn finished, so `accessed` reflects
3988
4021
  // whether customer code obtained the branch URL during this
3989
4022
  // item. Omitted entirely when no lease was attached, so the
@@ -4229,6 +4262,7 @@ var Bitfab = class {
4229
4262
  traceFunctionKey: params.traceFunctionKey,
4230
4263
  externalTrace: rawTrace,
4231
4264
  completed: true,
4265
+ ...params.dropped && { dropped: true },
4232
4266
  ...params.sessionId && { sessionId: params.sessionId },
4233
4267
  ...params.testRunId && { testRunId: params.testRunId }
4234
4268
  });