@bitfab/sdk 0.36.9 → 0.36.11
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-MBKY42QC.js → chunk-EKOAKLZC.js} +100 -22
- package/dist/chunk-EKOAKLZC.js.map +1 -0
- package/dist/{chunk-TJAFKZ4X.js → chunk-VDFPZYLH.js} +3 -3
- package/dist/index.cjs +99 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +2 -2
- package/dist/node.cjs +99 -21
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +2 -2
- package/dist/{replay-MH5QFXET.js → replay-TW3ONJ3W.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-MBKY42QC.js.map +0 -1
- /package/dist/{chunk-TJAFKZ4X.js.map → chunk-VDFPZYLH.js.map} +0 -0
- /package/dist/{replay-MH5QFXET.js.map → replay-TW3ONJ3W.js.map} +0 -0
|
@@ -98,7 +98,7 @@ async function captureCodeChangeFromGit(cwd, label) {
|
|
|
98
98
|
const tracked = await git(root, [
|
|
99
99
|
"diff",
|
|
100
100
|
"--name-status",
|
|
101
|
-
"--
|
|
101
|
+
"--find-renames",
|
|
102
102
|
"-z",
|
|
103
103
|
base,
|
|
104
104
|
"--",
|
|
@@ -114,23 +114,23 @@ async function captureCodeChangeFromGit(cwd, label) {
|
|
|
114
114
|
]);
|
|
115
115
|
const entries = [
|
|
116
116
|
...parseNameStatusZ(tracked ?? ""),
|
|
117
|
-
...(untracked ?? "").split(NUL).filter((p) => p.length > 0).map((path) => ({ status: "A", path }))
|
|
117
|
+
...(untracked ?? "").split(NUL).filter((p) => p.length > 0).map((path) => ({ status: "A", beforePath: path, path }))
|
|
118
118
|
];
|
|
119
119
|
if (entries.length === 0) {
|
|
120
120
|
return null;
|
|
121
121
|
}
|
|
122
122
|
const files = [];
|
|
123
123
|
let totalBytes = 0;
|
|
124
|
-
for (const { status, path } of entries) {
|
|
124
|
+
for (const { status, beforePath, path } of entries) {
|
|
125
125
|
if (files.length >= MAX_FILES) {
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
|
-
const beforeBytes = status === "A" ? 0 : await blobBytes(base,
|
|
128
|
+
const beforeBytes = status === "A" ? 0 : await blobBytes(base, beforePath);
|
|
129
129
|
const afterBytes = status === "D" ? 0 : await workingBytes(path);
|
|
130
130
|
if (beforeBytes > MAX_FILE_BYTES || afterBytes > MAX_FILE_BYTES) {
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
|
-
const before = (status === "A" ? "" : await git(root, ["show", `${base}:${
|
|
133
|
+
const before = (status === "A" ? "" : await git(root, ["show", `${base}:${beforePath}`]) ?? "").replace(/\r\n/g, "\n");
|
|
134
134
|
const after = (status === "D" ? "" : await readWorkingFile(readFile, root, path)).replace(/\r\n/g, "\n");
|
|
135
135
|
if (before === after) {
|
|
136
136
|
continue;
|
|
@@ -188,8 +188,18 @@ async function readWorkingFile(readFile, root, path) {
|
|
|
188
188
|
function parseNameStatusZ(raw) {
|
|
189
189
|
const parts = raw.split(NUL).filter((p) => p.length > 0);
|
|
190
190
|
const out = [];
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
let i = 0;
|
|
192
|
+
while (i + 1 < parts.length) {
|
|
193
|
+
const status = parts[i].charAt(0);
|
|
194
|
+
i += 1;
|
|
195
|
+
const beforePath = parts[i];
|
|
196
|
+
i += 1;
|
|
197
|
+
if ((status === "R" || status === "C") && i < parts.length) {
|
|
198
|
+
out.push({ status, beforePath, path: parts[i] });
|
|
199
|
+
i += 1;
|
|
200
|
+
} else {
|
|
201
|
+
out.push({ status, beforePath, path: beforePath });
|
|
202
|
+
}
|
|
193
203
|
}
|
|
194
204
|
return out;
|
|
195
205
|
}
|
|
@@ -304,7 +314,7 @@ function encodeRequestBody(body) {
|
|
|
304
314
|
}
|
|
305
315
|
|
|
306
316
|
// src/version.generated.ts
|
|
307
|
-
var __version__ = "0.36.
|
|
317
|
+
var __version__ = "0.36.11";
|
|
308
318
|
|
|
309
319
|
// src/constants.ts
|
|
310
320
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1503,6 +1513,10 @@ var HttpClient = class {
|
|
|
1503
1513
|
...error instanceof BitfabError && error.retryAfterMs !== void 0 ? { retryAfterMs: error.retryAfterMs } : {}
|
|
1504
1514
|
});
|
|
1505
1515
|
}
|
|
1516
|
+
const serverTraceIds = asPayloadRecord(response?.traceIds);
|
|
1517
|
+
if (serverTraceIds !== void 0) {
|
|
1518
|
+
this.recordServerTraceIds(serverTraceIds);
|
|
1519
|
+
}
|
|
1506
1520
|
const partialSuccess = asPayloadRecord(response?.partialSuccess);
|
|
1507
1521
|
const rejected = partialSuccess?.rejectedSpans;
|
|
1508
1522
|
if (rejected !== void 0 && rejected !== "0" && rejected !== 0) {
|
|
@@ -1527,6 +1541,14 @@ var HttpClient = class {
|
|
|
1527
1541
|
}
|
|
1528
1542
|
}
|
|
1529
1543
|
}
|
|
1544
|
+
/**
|
|
1545
|
+
* The server's assigned `traces.id` for a tracked trace if it has already
|
|
1546
|
+
* been read back off an ingest response, without stopping tracking. Lets a
|
|
1547
|
+
* replay surface the id mid-run for items whose spans already landed.
|
|
1548
|
+
*/
|
|
1549
|
+
peekServerTraceId(traceId) {
|
|
1550
|
+
return this.traceDeliveries.get(traceId)?.serverTraceId;
|
|
1551
|
+
}
|
|
1530
1552
|
/** Whether any tracked trace has had its closing carrier submitted. */
|
|
1531
1553
|
hasClosedDeliveries(traceIds) {
|
|
1532
1554
|
return traceIds.some((traceId) => this.traceDeliveries.get(traceId)?.closed);
|
|
@@ -1553,7 +1575,8 @@ var HttpClient = class {
|
|
|
1553
1575
|
closed: delivery.closed,
|
|
1554
1576
|
delivered: delivery.closingAcked && [...delivery.submittedSpanIds].every(
|
|
1555
1577
|
(spanId) => delivery.ackedSpanIds.has(spanId)
|
|
1556
|
-
)
|
|
1578
|
+
),
|
|
1579
|
+
serverTraceId: delivery.serverTraceId
|
|
1557
1580
|
};
|
|
1558
1581
|
}
|
|
1559
1582
|
return reports;
|
|
@@ -1582,6 +1605,23 @@ var HttpClient = class {
|
|
|
1582
1605
|
* delivered ref is proof its row exists: the same fact the replay status
|
|
1583
1606
|
* endpoint would report, already in hand.
|
|
1584
1607
|
*/
|
|
1608
|
+
/**
|
|
1609
|
+
* Record the server's assigned `traces.id` for each tracked source trace,
|
|
1610
|
+
* read back from the OTLP ingest response. Keyed by source trace id, the same
|
|
1611
|
+
* key the delivery ledger uses. Untracked ids are ignored.
|
|
1612
|
+
*/
|
|
1613
|
+
recordServerTraceIds(map) {
|
|
1614
|
+
for (const [sourceTraceId, serverTraceId] of Object.entries(map)) {
|
|
1615
|
+
if (typeof serverTraceId !== "string") {
|
|
1616
|
+
continue;
|
|
1617
|
+
}
|
|
1618
|
+
const delivery = this.traceDeliveries.get(sourceTraceId);
|
|
1619
|
+
if (delivery === void 0) {
|
|
1620
|
+
continue;
|
|
1621
|
+
}
|
|
1622
|
+
delivery.serverTraceId = serverTraceId;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1585
1625
|
recordDeliveredCarriers(refs) {
|
|
1586
1626
|
for (const ref of refs) {
|
|
1587
1627
|
const delivery = this.traceDeliveries.get(ref.traceId);
|
|
@@ -2511,13 +2551,17 @@ async function waitForReplayPersistence(httpClient, testRunId, replayedTraceIds)
|
|
|
2511
2551
|
}
|
|
2512
2552
|
if (!httpClient.hasClosedDeliveries(replayedTraceIds)) {
|
|
2513
2553
|
httpClient.takeTraceDeliveries(replayedTraceIds);
|
|
2514
|
-
return;
|
|
2554
|
+
return {};
|
|
2515
2555
|
}
|
|
2516
2556
|
const flushed = await flushTraces(REPLAY_PERSISTENCE_TIMEOUT_MS);
|
|
2517
2557
|
const deliveries = httpClient.takeTraceDeliveries(replayedTraceIds);
|
|
2518
2558
|
const expectedSpanCounts = {};
|
|
2559
|
+
const readBackTraceIds = {};
|
|
2519
2560
|
let allDelivered = true;
|
|
2520
2561
|
for (const [traceId, delivery] of Object.entries(deliveries)) {
|
|
2562
|
+
if (delivery.serverTraceId !== void 0) {
|
|
2563
|
+
readBackTraceIds[traceId] = delivery.serverTraceId;
|
|
2564
|
+
}
|
|
2521
2565
|
if (!delivery.closed) {
|
|
2522
2566
|
continue;
|
|
2523
2567
|
}
|
|
@@ -2525,7 +2569,7 @@ async function waitForReplayPersistence(httpClient, testRunId, replayedTraceIds)
|
|
|
2525
2569
|
allDelivered = allDelivered && delivery.delivered;
|
|
2526
2570
|
}
|
|
2527
2571
|
if (allDelivered) {
|
|
2528
|
-
return;
|
|
2572
|
+
return readBackTraceIds;
|
|
2529
2573
|
}
|
|
2530
2574
|
const deadline = Date.now() + REPLAY_PERSISTENCE_TIMEOUT_MS;
|
|
2531
2575
|
let missing = Object.keys(expectedSpanCounts).length;
|
|
@@ -2539,7 +2583,7 @@ async function waitForReplayPersistence(httpClient, testRunId, replayedTraceIds)
|
|
|
2539
2583
|
(traceId) => ready[traceId] === void 0
|
|
2540
2584
|
).length;
|
|
2541
2585
|
if (missing === 0) {
|
|
2542
|
-
return;
|
|
2586
|
+
return readBackTraceIds;
|
|
2543
2587
|
}
|
|
2544
2588
|
if (Date.now() >= deadline) {
|
|
2545
2589
|
break;
|
|
@@ -2567,7 +2611,7 @@ async function mapWithConcurrency2(tasks, maxConcurrency, onSettled, onStarted)
|
|
|
2567
2611
|
onStarted?.(index);
|
|
2568
2612
|
const result = await tasks[index]();
|
|
2569
2613
|
results[index] = result;
|
|
2570
|
-
onSettled?.(result, index);
|
|
2614
|
+
await onSettled?.(result, index);
|
|
2571
2615
|
}
|
|
2572
2616
|
}
|
|
2573
2617
|
const workers = Array.from(
|
|
@@ -2657,10 +2701,36 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
2657
2701
|
let started = 0;
|
|
2658
2702
|
let succeeded = 0;
|
|
2659
2703
|
let errored = 0;
|
|
2704
|
+
let flushInFlight = null;
|
|
2705
|
+
let flushPending = false;
|
|
2706
|
+
const flushFinishedItemTrace = () => {
|
|
2707
|
+
flushPending = true;
|
|
2708
|
+
if (!flushInFlight) {
|
|
2709
|
+
flushInFlight = (async () => {
|
|
2710
|
+
try {
|
|
2711
|
+
while (flushPending) {
|
|
2712
|
+
flushPending = false;
|
|
2713
|
+
await httpClient.settleDeferredWork(REPLAY_PERSISTENCE_TIMEOUT_MS);
|
|
2714
|
+
await flushTraces(REPLAY_PERSISTENCE_TIMEOUT_MS);
|
|
2715
|
+
}
|
|
2716
|
+
} finally {
|
|
2717
|
+
flushInFlight = null;
|
|
2718
|
+
}
|
|
2719
|
+
})();
|
|
2720
|
+
}
|
|
2721
|
+
return flushInFlight;
|
|
2722
|
+
};
|
|
2660
2723
|
const resultItems = await mapWithConcurrency2(
|
|
2661
2724
|
tasks,
|
|
2662
2725
|
maxConcurrency,
|
|
2663
|
-
(item) => {
|
|
2726
|
+
async (item, index) => {
|
|
2727
|
+
let serverTraceId = null;
|
|
2728
|
+
try {
|
|
2729
|
+
await flushFinishedItemTrace();
|
|
2730
|
+
serverTraceId = httpClient.peekServerTraceId(replayedTraceIds[index]) ?? null;
|
|
2731
|
+
} catch {
|
|
2732
|
+
}
|
|
2733
|
+
item.traceId = serverTraceId;
|
|
2664
2734
|
completed += 1;
|
|
2665
2735
|
if (item.error === null) {
|
|
2666
2736
|
succeeded += 1;
|
|
@@ -2675,11 +2745,12 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
2675
2745
|
succeeded,
|
|
2676
2746
|
errored,
|
|
2677
2747
|
item: {
|
|
2678
|
-
// The server
|
|
2679
|
-
//
|
|
2680
|
-
//
|
|
2681
|
-
//
|
|
2682
|
-
|
|
2748
|
+
// The server's assigned traces.id, read back off the ingest
|
|
2749
|
+
// response and surfaced as this item finishes. Null only if the
|
|
2750
|
+
// per-item flush could not confirm delivery in time; the end-of-run
|
|
2751
|
+
// barrier then fills the returned ReplayItem. The client-side
|
|
2752
|
+
// placeholder is never surfaced.
|
|
2753
|
+
traceId: serverTraceId,
|
|
2683
2754
|
originalTraceId: item.originalTraceId ?? null,
|
|
2684
2755
|
originalSpanId: item.originalSpanId ?? null,
|
|
2685
2756
|
// Deprecated aliases for originalTraceId/originalSpanId.
|
|
@@ -2725,12 +2796,19 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
2725
2796
|
}
|
|
2726
2797
|
} : void 0
|
|
2727
2798
|
);
|
|
2728
|
-
await preserveReplayFailure(
|
|
2799
|
+
const deliveredTraceIds = await preserveReplayFailure(
|
|
2729
2800
|
() => waitForReplayPersistence(httpClient, testRunId, replayedTraceIds),
|
|
2730
2801
|
resultItems,
|
|
2731
2802
|
testRunId,
|
|
2732
2803
|
fullTestRunUrl
|
|
2733
2804
|
);
|
|
2805
|
+
for (let index = 0; index < resultItems.length; index += 1) {
|
|
2806
|
+
const localId = replayedTraceIds[index];
|
|
2807
|
+
const readBack = localId ? deliveredTraceIds[localId] : void 0;
|
|
2808
|
+
if (readBack !== void 0) {
|
|
2809
|
+
resultItems[index].traceId = readBack;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2734
2812
|
const completeResult = await preserveReplayFailure(
|
|
2735
2813
|
() => httpClient.completeReplay(testRunId),
|
|
2736
2814
|
resultItems,
|
|
@@ -2746,7 +2824,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
2746
2824
|
const item = resultItems[index];
|
|
2747
2825
|
const localId = replayedTraceIds[index];
|
|
2748
2826
|
const mapped = localId ? serverTraceIds[localId] : void 0;
|
|
2749
|
-
item.traceId = mapped ?? null;
|
|
2827
|
+
item.traceId = item.traceId ?? mapped ?? null;
|
|
2750
2828
|
if (item.error === null) {
|
|
2751
2829
|
completedCount += 1;
|
|
2752
2830
|
if (mapped === void 0) {
|
|
@@ -2855,4 +2933,4 @@ export {
|
|
|
2855
2933
|
sleepForReplayPersistence,
|
|
2856
2934
|
replay
|
|
2857
2935
|
};
|
|
2858
|
-
//# sourceMappingURL=chunk-
|
|
2936
|
+
//# sourceMappingURL=chunk-EKOAKLZC.js.map
|