bitfab 0.29.0 → 0.29.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/{chunk-2M5AWVVQ.js → chunk-RTPEBWVO.js} +10 -7
- package/dist/chunk-RTPEBWVO.js.map +1 -0
- package/dist/{chunk-V3XORTWI.js → chunk-YZU6WFG2.js} +73 -52
- package/dist/chunk-YZU6WFG2.js.map +1 -0
- package/dist/index.cjs +79 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -14
- package/dist/index.d.ts +55 -14
- package/dist/index.js +2 -2
- package/dist/node.cjs +79 -55
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +2 -2
- package/dist/{replay-HEGU3YU2.js → replay-SKW5A7II.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-2M5AWVVQ.js.map +0 -1
- package/dist/chunk-V3XORTWI.js.map +0 -1
- /package/dist/{replay-HEGU3YU2.js.map → replay-SKW5A7II.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -785,6 +785,21 @@ interface ReplayOptions {
|
|
|
785
785
|
}
|
|
786
786
|
/** Running totals reported to {@link ReplayOptions.onProgress} as replay proceeds. */
|
|
787
787
|
interface ReplayProgress {
|
|
788
|
+
/**
|
|
789
|
+
* Event kind. Omitted (or `"item"`) for the per-trace settle events streamed
|
|
790
|
+
* during the run. `"complete"` marks the single terminal event emitted once
|
|
791
|
+
* the run has settled and been enriched server-side; it carries the full
|
|
792
|
+
* {@link ReplayProgress.result} and has no `item`. The Bitfab plugin reads
|
|
793
|
+
* that terminal event to build the run's final result without parsing stdout.
|
|
794
|
+
*/
|
|
795
|
+
type?: "item" | "complete";
|
|
796
|
+
/**
|
|
797
|
+
* The full {@link ReplayResult}, present only on the terminal `"complete"`
|
|
798
|
+
* event. Lets the plugin ingest the enriched result (server-aggregated tokens,
|
|
799
|
+
* server trace ids) over the same channel as progress, so a dependency logging
|
|
800
|
+
* to stdout can never block it.
|
|
801
|
+
*/
|
|
802
|
+
result?: ReplayResult<unknown>;
|
|
788
803
|
/** Test run ID created for this replay. */
|
|
789
804
|
testRunId?: string;
|
|
790
805
|
/** Items that have finished so far, whether they succeeded or errored. */
|
|
@@ -796,18 +811,25 @@ interface ReplayProgress {
|
|
|
796
811
|
/** Of the completed items, how many threw (their `item.error` is set). */
|
|
797
812
|
errored: number;
|
|
798
813
|
/**
|
|
799
|
-
* The single item that just settled to produce this event. `traceId` is
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
814
|
+
* The single item that just settled to produce this event. `traceId` is null
|
|
815
|
+
* at this stage (the server replay id isn't known until the run completes);
|
|
816
|
+
* `originalTraceId` is the original (historical) trace that was replayed (so
|
|
817
|
+
* a UI can identify or link it); `error` is its replay error, or null when it
|
|
818
|
+
* ran ok; `durationMs` is how long this one trace took to replay. Lets a
|
|
819
|
+
* progress UI show per-trace pass/fail and timing as the run streams, without
|
|
820
|
+
* waiting for the full {@link ReplayResult}.
|
|
805
821
|
*/
|
|
806
822
|
item?: {
|
|
807
|
-
/**
|
|
808
|
-
traceId
|
|
809
|
-
/**
|
|
810
|
-
|
|
823
|
+
/** Trace ID of the new replay trace (null during the run; the server id arrives at completion). */
|
|
824
|
+
traceId?: string | null;
|
|
825
|
+
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
826
|
+
originalTraceId: string | null;
|
|
827
|
+
/** External span ID the recorded inputs were read from (the original root span). */
|
|
828
|
+
originalSpanId?: string | null;
|
|
829
|
+
/** @deprecated alias for `originalTraceId`. */
|
|
830
|
+
sourceTraceId: string | null;
|
|
831
|
+
/** @deprecated alias for `originalSpanId`. */
|
|
832
|
+
sourceSpanId?: string | null;
|
|
811
833
|
/** Deserialized inputs from the original trace. */
|
|
812
834
|
input?: unknown[];
|
|
813
835
|
/** The result returned by the replayed function, or undefined on error. */
|
|
@@ -847,9 +869,13 @@ declare const BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
|
|
|
847
869
|
declare function reportReplayProgress(progress: ReplayProgress): void;
|
|
848
870
|
/** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
|
|
849
871
|
interface AdaptContext {
|
|
850
|
-
/** Bitfab trace ID of the historical trace being replayed. */
|
|
851
|
-
|
|
872
|
+
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
873
|
+
originalTraceId: string;
|
|
852
874
|
/** External span ID the recorded inputs were read from. */
|
|
875
|
+
originalSpanId: string;
|
|
876
|
+
/** @deprecated alias for {@link AdaptContext.originalTraceId}. */
|
|
877
|
+
sourceTraceId: string;
|
|
878
|
+
/** @deprecated alias for {@link AdaptContext.originalSpanId}. */
|
|
853
879
|
sourceSpanId: string;
|
|
854
880
|
}
|
|
855
881
|
/**
|
|
@@ -865,8 +891,23 @@ interface AdaptContext {
|
|
|
865
891
|
*/
|
|
866
892
|
type AdaptInputsFn = (inputs: unknown[], ctx: AdaptContext) => unknown[];
|
|
867
893
|
interface ReplayItem<T> {
|
|
868
|
-
/**
|
|
894
|
+
/**
|
|
895
|
+
* Server trace ID of the new replay trace this item produced. Written in by
|
|
896
|
+
* `replay()` from the complete-replay response once the server has minted the
|
|
897
|
+
* trace row; the client-side id used to correlate spans during the run is
|
|
898
|
+
* never surfaced here. Null until completion, on older servers that omit the
|
|
899
|
+
* mapping, or if the item produced no trace. Not the verdict-persistence key:
|
|
900
|
+
* that is the original-trace lineage (`originalTraceId` + `testRunId`).
|
|
901
|
+
*/
|
|
869
902
|
traceId: string | null;
|
|
903
|
+
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
904
|
+
originalTraceId: string;
|
|
905
|
+
/** External span ID the recorded inputs were read from (the original root span). */
|
|
906
|
+
originalSpanId: string;
|
|
907
|
+
/** @deprecated alias for {@link ReplayItem.originalTraceId}. */
|
|
908
|
+
sourceTraceId: string;
|
|
909
|
+
/** @deprecated alias for {@link ReplayItem.originalSpanId}. */
|
|
910
|
+
sourceSpanId: string;
|
|
870
911
|
/** Deserialized inputs from the original trace. */
|
|
871
912
|
input: unknown[];
|
|
872
913
|
/** The result returned by the function during replay, or undefined on error. */
|
|
@@ -1758,7 +1799,7 @@ declare class BitfabFunction {
|
|
|
1758
1799
|
/**
|
|
1759
1800
|
* SDK version from package.json (injected at build time)
|
|
1760
1801
|
*/
|
|
1761
|
-
declare const __version__ = "0.29.
|
|
1802
|
+
declare const __version__ = "0.29.1";
|
|
1762
1803
|
|
|
1763
1804
|
/**
|
|
1764
1805
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -785,6 +785,21 @@ interface ReplayOptions {
|
|
|
785
785
|
}
|
|
786
786
|
/** Running totals reported to {@link ReplayOptions.onProgress} as replay proceeds. */
|
|
787
787
|
interface ReplayProgress {
|
|
788
|
+
/**
|
|
789
|
+
* Event kind. Omitted (or `"item"`) for the per-trace settle events streamed
|
|
790
|
+
* during the run. `"complete"` marks the single terminal event emitted once
|
|
791
|
+
* the run has settled and been enriched server-side; it carries the full
|
|
792
|
+
* {@link ReplayProgress.result} and has no `item`. The Bitfab plugin reads
|
|
793
|
+
* that terminal event to build the run's final result without parsing stdout.
|
|
794
|
+
*/
|
|
795
|
+
type?: "item" | "complete";
|
|
796
|
+
/**
|
|
797
|
+
* The full {@link ReplayResult}, present only on the terminal `"complete"`
|
|
798
|
+
* event. Lets the plugin ingest the enriched result (server-aggregated tokens,
|
|
799
|
+
* server trace ids) over the same channel as progress, so a dependency logging
|
|
800
|
+
* to stdout can never block it.
|
|
801
|
+
*/
|
|
802
|
+
result?: ReplayResult<unknown>;
|
|
788
803
|
/** Test run ID created for this replay. */
|
|
789
804
|
testRunId?: string;
|
|
790
805
|
/** Items that have finished so far, whether they succeeded or errored. */
|
|
@@ -796,18 +811,25 @@ interface ReplayProgress {
|
|
|
796
811
|
/** Of the completed items, how many threw (their `item.error` is set). */
|
|
797
812
|
errored: number;
|
|
798
813
|
/**
|
|
799
|
-
* The single item that just settled to produce this event. `traceId` is
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
*
|
|
804
|
-
*
|
|
814
|
+
* The single item that just settled to produce this event. `traceId` is null
|
|
815
|
+
* at this stage (the server replay id isn't known until the run completes);
|
|
816
|
+
* `originalTraceId` is the original (historical) trace that was replayed (so
|
|
817
|
+
* a UI can identify or link it); `error` is its replay error, or null when it
|
|
818
|
+
* ran ok; `durationMs` is how long this one trace took to replay. Lets a
|
|
819
|
+
* progress UI show per-trace pass/fail and timing as the run streams, without
|
|
820
|
+
* waiting for the full {@link ReplayResult}.
|
|
805
821
|
*/
|
|
806
822
|
item?: {
|
|
807
|
-
/**
|
|
808
|
-
traceId
|
|
809
|
-
/**
|
|
810
|
-
|
|
823
|
+
/** Trace ID of the new replay trace (null during the run; the server id arrives at completion). */
|
|
824
|
+
traceId?: string | null;
|
|
825
|
+
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
826
|
+
originalTraceId: string | null;
|
|
827
|
+
/** External span ID the recorded inputs were read from (the original root span). */
|
|
828
|
+
originalSpanId?: string | null;
|
|
829
|
+
/** @deprecated alias for `originalTraceId`. */
|
|
830
|
+
sourceTraceId: string | null;
|
|
831
|
+
/** @deprecated alias for `originalSpanId`. */
|
|
832
|
+
sourceSpanId?: string | null;
|
|
811
833
|
/** Deserialized inputs from the original trace. */
|
|
812
834
|
input?: unknown[];
|
|
813
835
|
/** The result returned by the replayed function, or undefined on error. */
|
|
@@ -847,9 +869,13 @@ declare const BITFAB_PROGRESS_PREFIX = "@@bitfab:progress ";
|
|
|
847
869
|
declare function reportReplayProgress(progress: ReplayProgress): void;
|
|
848
870
|
/** Per-trace context passed to {@link ReplayOptions.adaptInputs}. */
|
|
849
871
|
interface AdaptContext {
|
|
850
|
-
/** Bitfab trace ID of the historical trace being replayed. */
|
|
851
|
-
|
|
872
|
+
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
873
|
+
originalTraceId: string;
|
|
852
874
|
/** External span ID the recorded inputs were read from. */
|
|
875
|
+
originalSpanId: string;
|
|
876
|
+
/** @deprecated alias for {@link AdaptContext.originalTraceId}. */
|
|
877
|
+
sourceTraceId: string;
|
|
878
|
+
/** @deprecated alias for {@link AdaptContext.originalSpanId}. */
|
|
853
879
|
sourceSpanId: string;
|
|
854
880
|
}
|
|
855
881
|
/**
|
|
@@ -865,8 +891,23 @@ interface AdaptContext {
|
|
|
865
891
|
*/
|
|
866
892
|
type AdaptInputsFn = (inputs: unknown[], ctx: AdaptContext) => unknown[];
|
|
867
893
|
interface ReplayItem<T> {
|
|
868
|
-
/**
|
|
894
|
+
/**
|
|
895
|
+
* Server trace ID of the new replay trace this item produced. Written in by
|
|
896
|
+
* `replay()` from the complete-replay response once the server has minted the
|
|
897
|
+
* trace row; the client-side id used to correlate spans during the run is
|
|
898
|
+
* never surfaced here. Null until completion, on older servers that omit the
|
|
899
|
+
* mapping, or if the item produced no trace. Not the verdict-persistence key:
|
|
900
|
+
* that is the original-trace lineage (`originalTraceId` + `testRunId`).
|
|
901
|
+
*/
|
|
869
902
|
traceId: string | null;
|
|
903
|
+
/** Bitfab trace ID of the original (historical) trace being replayed. */
|
|
904
|
+
originalTraceId: string;
|
|
905
|
+
/** External span ID the recorded inputs were read from (the original root span). */
|
|
906
|
+
originalSpanId: string;
|
|
907
|
+
/** @deprecated alias for {@link ReplayItem.originalTraceId}. */
|
|
908
|
+
sourceTraceId: string;
|
|
909
|
+
/** @deprecated alias for {@link ReplayItem.originalSpanId}. */
|
|
910
|
+
sourceSpanId: string;
|
|
870
911
|
/** Deserialized inputs from the original trace. */
|
|
871
912
|
input: unknown[];
|
|
872
913
|
/** The result returned by the function during replay, or undefined on error. */
|
|
@@ -1758,7 +1799,7 @@ declare class BitfabFunction {
|
|
|
1758
1799
|
/**
|
|
1759
1800
|
* SDK version from package.json (injected at build time)
|
|
1760
1801
|
*/
|
|
1761
|
-
declare const __version__ = "0.29.
|
|
1802
|
+
declare const __version__ = "0.29.1";
|
|
1762
1803
|
|
|
1763
1804
|
/**
|
|
1764
1805
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
|
@@ -23,12 +23,12 @@ import {
|
|
|
23
23
|
flushTraces,
|
|
24
24
|
getCurrentSpan,
|
|
25
25
|
getCurrentTrace
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-RTPEBWVO.js";
|
|
27
27
|
import {
|
|
28
28
|
BITFAB_PROGRESS_PREFIX,
|
|
29
29
|
BitfabError,
|
|
30
30
|
reportReplayProgress
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-YZU6WFG2.js";
|
|
32
32
|
export {
|
|
33
33
|
BITFAB_PROGRESS_PREFIX,
|
|
34
34
|
Bitfab,
|
package/dist/node.cjs
CHANGED
|
@@ -403,23 +403,27 @@ function buildMockTree(rootNode) {
|
|
|
403
403
|
}
|
|
404
404
|
return { spans };
|
|
405
405
|
}
|
|
406
|
-
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, environment, adaptInputs) {
|
|
406
|
+
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, environment, adaptInputs) {
|
|
407
407
|
const lease = environment ? serverItem.dbBranchLease : void 0;
|
|
408
408
|
let inputs = [];
|
|
409
409
|
let originalOutput;
|
|
410
410
|
let result;
|
|
411
411
|
let error = null;
|
|
412
|
-
const replayedTraceId = randomUuid();
|
|
413
412
|
const pendingPersistence = [];
|
|
413
|
+
const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
|
|
414
|
+
const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
|
|
414
415
|
try {
|
|
415
|
-
const span = await httpClient.getExternalSpan(
|
|
416
|
+
const span = await httpClient.getExternalSpan(originalSpanId);
|
|
416
417
|
const spanData = span.rawData?.span_data ?? {};
|
|
417
418
|
inputs = deserializeInputs(spanData);
|
|
418
419
|
originalOutput = deserializeOutput(spanData);
|
|
419
420
|
if (adaptInputs) {
|
|
420
421
|
inputs = adaptInputs(inputs, {
|
|
421
|
-
|
|
422
|
-
|
|
422
|
+
originalTraceId,
|
|
423
|
+
originalSpanId,
|
|
424
|
+
// Deprecated aliases for originalTraceId/originalSpanId.
|
|
425
|
+
sourceTraceId: originalTraceId,
|
|
426
|
+
sourceSpanId: originalSpanId
|
|
423
427
|
});
|
|
424
428
|
}
|
|
425
429
|
const hasOverrides = resolvedOverrides.length > 0;
|
|
@@ -428,15 +432,14 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
428
432
|
let mockTree;
|
|
429
433
|
if (needTree) {
|
|
430
434
|
try {
|
|
431
|
-
const treeResponse = await httpClient.getSpanTree(
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
);
|
|
435
|
+
const treeResponse = await httpClient.getSpanTree(originalSpanId, {
|
|
436
|
+
includeOutputs
|
|
437
|
+
});
|
|
435
438
|
if (treeResponse.root) {
|
|
436
439
|
mockTree = buildMockTree(treeResponse.root);
|
|
437
440
|
} else if (mockStrategy === "all" || hasOverrides) {
|
|
438
441
|
throw new BitfabError(
|
|
439
|
-
`Replay mock strategy "${mockStrategy}"${hasOverrides ? " with overrides" : ""} requires a span tree root for
|
|
442
|
+
`Replay mock strategy "${mockStrategy}"${hasOverrides ? " with overrides" : ""} requires a span tree root for original span ${originalSpanId}.`
|
|
440
443
|
);
|
|
441
444
|
} else {
|
|
442
445
|
mockTree = void 0;
|
|
@@ -467,7 +470,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
467
470
|
traceId: replayedTraceId,
|
|
468
471
|
inputSourceSpanId: span.id,
|
|
469
472
|
inputSourceTraceId: span.externalTraceId,
|
|
470
|
-
sourceBitfabTraceId:
|
|
473
|
+
sourceBitfabTraceId: originalTraceId,
|
|
471
474
|
mockTree,
|
|
472
475
|
callCounters: mockTree ? /* @__PURE__ */ new Map() : void 0,
|
|
473
476
|
mockStrategy,
|
|
@@ -497,7 +500,15 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
497
500
|
}
|
|
498
501
|
}
|
|
499
502
|
return {
|
|
500
|
-
|
|
503
|
+
// Written in by replay() from the complete-replay response once the server
|
|
504
|
+
// has minted this replay trace's row. Null until then: the client-side
|
|
505
|
+
// correlation id (replayedTraceId) is never surfaced as the item's traceId.
|
|
506
|
+
traceId: null,
|
|
507
|
+
originalTraceId,
|
|
508
|
+
originalSpanId,
|
|
509
|
+
// Deprecated aliases for originalTraceId/originalSpanId.
|
|
510
|
+
sourceTraceId: originalTraceId,
|
|
511
|
+
sourceSpanId: originalSpanId,
|
|
501
512
|
input: inputs,
|
|
502
513
|
result,
|
|
503
514
|
originalOutput,
|
|
@@ -573,14 +584,16 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
573
584
|
...normalizeMockOverrides(options?.mockOverride),
|
|
574
585
|
...registeredOverrides
|
|
575
586
|
];
|
|
587
|
+
const replayedTraceIds = serverItems.map(() => randomUuid());
|
|
576
588
|
const tasks = serverItems.map(
|
|
577
|
-
(serverItem) => () => processItem(
|
|
589
|
+
(serverItem, index) => () => processItem(
|
|
578
590
|
httpClient,
|
|
579
591
|
serverItem,
|
|
580
592
|
fn,
|
|
581
593
|
testRunId,
|
|
582
594
|
mockStrategy,
|
|
583
595
|
resolvedOverrides,
|
|
596
|
+
replayedTraceIds[index],
|
|
584
597
|
options?.environment,
|
|
585
598
|
options?.adaptInputs
|
|
586
599
|
)
|
|
@@ -607,11 +620,17 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
607
620
|
succeeded,
|
|
608
621
|
errored,
|
|
609
622
|
item: {
|
|
610
|
-
//
|
|
611
|
-
//
|
|
612
|
-
//
|
|
613
|
-
|
|
614
|
-
|
|
623
|
+
// The server replay trace id isn't known until completeReplay
|
|
624
|
+
// runs (below), so it can't be reported mid-run and we never
|
|
625
|
+
// emit the client-side placeholder. originalTraceId (the
|
|
626
|
+
// historical trace) is known now and is what a UI keys on to
|
|
627
|
+
// identify what just settled.
|
|
628
|
+
traceId: null,
|
|
629
|
+
originalTraceId: item.originalTraceId ?? null,
|
|
630
|
+
originalSpanId: item.originalSpanId ?? null,
|
|
631
|
+
// Deprecated aliases for originalTraceId/originalSpanId.
|
|
632
|
+
sourceTraceId: item.originalTraceId ?? null,
|
|
633
|
+
sourceSpanId: item.originalSpanId ?? null,
|
|
615
634
|
input: item.input,
|
|
616
635
|
result: item.result,
|
|
617
636
|
originalOutput: item.originalOutput,
|
|
@@ -629,56 +648,58 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
629
648
|
const completeResult = await httpClient.completeReplay(testRunId);
|
|
630
649
|
const serverTraceIds = completeResult.traceIds;
|
|
631
650
|
const replayTokens = completeResult.tokens;
|
|
632
|
-
if (serverTraceIds
|
|
633
|
-
try {
|
|
634
|
-
console.warn(
|
|
635
|
-
"Bitfab: server did not return replay trace IDs; item.traceId will be null (server upgrade required for verdict persistence)"
|
|
636
|
-
);
|
|
637
|
-
} catch {
|
|
638
|
-
}
|
|
639
|
-
for (const item of resultItems) {
|
|
640
|
-
item.traceId = null;
|
|
641
|
-
}
|
|
642
|
-
} else {
|
|
651
|
+
if (serverTraceIds !== void 0) {
|
|
643
652
|
const missing = [];
|
|
644
653
|
let completedCount = 0;
|
|
645
|
-
for (
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
if (mapped !== void 0) {
|
|
655
|
-
item.tokens = replayTokens?.[mapped] ?? null;
|
|
654
|
+
for (let index = 0; index < resultItems.length; index += 1) {
|
|
655
|
+
const item = resultItems[index];
|
|
656
|
+
const localId = replayedTraceIds[index];
|
|
657
|
+
const mapped = localId ? serverTraceIds[localId] : void 0;
|
|
658
|
+
item.traceId = mapped ?? null;
|
|
659
|
+
if (item.error === null) {
|
|
660
|
+
completedCount += 1;
|
|
661
|
+
if (mapped === void 0) {
|
|
662
|
+
missing.push(localId ?? item.originalTraceId);
|
|
656
663
|
}
|
|
657
|
-
|
|
664
|
+
}
|
|
665
|
+
if (mapped !== void 0) {
|
|
666
|
+
item.tokens = replayTokens?.[mapped] ?? null;
|
|
658
667
|
}
|
|
659
668
|
}
|
|
660
|
-
if (missing.length
|
|
669
|
+
if (completedCount > 0 && missing.length === completedCount) {
|
|
661
670
|
const serverCount = completeResult.traceCount !== void 0 ? ` The server persisted ${completeResult.traceCount} trace(s) for this run.` : "";
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
671
|
+
throw new BitfabError(
|
|
672
|
+
`Replay completed but the server has no persisted trace for any of the ${completedCount} completed item(s) (testRunId ${testRunId}).${serverCount} Trace uploads were awaited, so either the uploads failed (check for "Bitfab: Failed to create" errors above) or the replayed function is not wrapped with withSpan.`
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
if (missing.length > 0) {
|
|
667
676
|
try {
|
|
668
677
|
console.error(
|
|
669
|
-
`Bitfab: server has no persisted trace for ${missing.length} of ${completedCount} completed replay item(s) (testRunId ${testRunId})
|
|
678
|
+
`Bitfab: server has no persisted trace for ${missing.length} of ${completedCount} completed replay item(s) (testRunId ${testRunId}). Their replay token usage is unavailable and they cannot be labeled.`
|
|
670
679
|
);
|
|
671
680
|
} catch {
|
|
672
681
|
}
|
|
673
682
|
}
|
|
674
683
|
}
|
|
675
|
-
const
|
|
684
|
+
const result = {
|
|
676
685
|
items: resultItems,
|
|
677
686
|
testRunId,
|
|
678
687
|
testRunUrl: `${serviceUrl}${testRunUrl}`
|
|
679
688
|
};
|
|
680
|
-
await writeReplayResultFile(
|
|
681
|
-
|
|
689
|
+
await writeReplayResultFile(result);
|
|
690
|
+
try {
|
|
691
|
+
options?.onProgress?.({
|
|
692
|
+
type: "complete",
|
|
693
|
+
testRunId,
|
|
694
|
+
completed: total,
|
|
695
|
+
total,
|
|
696
|
+
succeeded,
|
|
697
|
+
errored,
|
|
698
|
+
result
|
|
699
|
+
});
|
|
700
|
+
} catch {
|
|
701
|
+
}
|
|
702
|
+
return result;
|
|
682
703
|
}
|
|
683
704
|
async function writeReplayResultFile(result) {
|
|
684
705
|
const resultPath = typeof process !== "undefined" ? process.env?.BITFAB_REPLAY_RESULT_PATH : void 0;
|
|
@@ -748,7 +769,7 @@ registerAsyncLocalStorageClass(
|
|
|
748
769
|
);
|
|
749
770
|
|
|
750
771
|
// src/version.generated.ts
|
|
751
|
-
var __version__ = "0.29.
|
|
772
|
+
var __version__ = "0.29.1";
|
|
752
773
|
|
|
753
774
|
// src/constants.ts
|
|
754
775
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -4178,7 +4199,7 @@ var Bitfab = class {
|
|
|
4178
4199
|
dbSnapshotUsage: {
|
|
4179
4200
|
neonBranchId: replayCtx.dbBranchLease.neonBranchId,
|
|
4180
4201
|
snapshotTimestamp: replayCtx.dbBranchLease.snapshotTimestamp,
|
|
4181
|
-
|
|
4202
|
+
originalTraceId: replayCtx.sourceBitfabTraceId,
|
|
4182
4203
|
accessed: replayCtx.dbSnapshotAccessed === true
|
|
4183
4204
|
}
|
|
4184
4205
|
}
|
|
@@ -4482,8 +4503,11 @@ var Bitfab = class {
|
|
|
4482
4503
|
...params.dbSnapshotUsage.snapshotTimestamp && {
|
|
4483
4504
|
snapshot_timestamp: params.dbSnapshotUsage.snapshotTimestamp
|
|
4484
4505
|
},
|
|
4485
|
-
...params.dbSnapshotUsage.
|
|
4486
|
-
|
|
4506
|
+
...params.dbSnapshotUsage.originalTraceId && {
|
|
4507
|
+
original_trace_id: params.dbSnapshotUsage.originalTraceId,
|
|
4508
|
+
// Deprecated wire alias, kept so this SDK still reports usage
|
|
4509
|
+
// against servers that predate the rename.
|
|
4510
|
+
source_trace_id: params.dbSnapshotUsage.originalTraceId
|
|
4487
4511
|
},
|
|
4488
4512
|
accessed: params.dbSnapshotUsage.accessed
|
|
4489
4513
|
};
|