bitfab 0.33.1 → 0.33.2
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-7UHJ67MH.js → chunk-A3WLV5VS.js} +25 -9
- package/dist/chunk-A3WLV5VS.js.map +1 -0
- package/dist/{chunk-ADUWXWWI.js → chunk-GT2GSQM2.js} +29 -6
- package/dist/chunk-GT2GSQM2.js.map +1 -0
- package/dist/index.cjs +51 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/node.cjs +51 -12
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +2 -2
- package/dist/{replay-EQPISJKC.js → replay-V4GLDFSU.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-7UHJ67MH.js.map +0 -1
- package/dist/chunk-ADUWXWWI.js.map +0 -1
- /package/dist/{replay-EQPISJKC.js.map → replay-V4GLDFSU.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1963,7 +1963,7 @@ declare class BitfabFunction {
|
|
|
1963
1963
|
/**
|
|
1964
1964
|
* SDK version from package.json (injected at build time)
|
|
1965
1965
|
*/
|
|
1966
|
-
declare const __version__ = "0.33.
|
|
1966
|
+
declare const __version__ = "0.33.2";
|
|
1967
1967
|
|
|
1968
1968
|
/**
|
|
1969
1969
|
* Constants for the Bitfab SDK.
|
package/dist/index.d.ts
CHANGED
|
@@ -1963,7 +1963,7 @@ declare class BitfabFunction {
|
|
|
1963
1963
|
/**
|
|
1964
1964
|
* SDK version from package.json (injected at build time)
|
|
1965
1965
|
*/
|
|
1966
|
-
declare const __version__ = "0.33.
|
|
1966
|
+
declare const __version__ = "0.33.2";
|
|
1967
1967
|
|
|
1968
1968
|
/**
|
|
1969
1969
|
* Constants for the Bitfab SDK.
|
package/dist/index.js
CHANGED
|
@@ -23,12 +23,12 @@ import {
|
|
|
23
23
|
getCurrentReplayBranch,
|
|
24
24
|
getCurrentSpan,
|
|
25
25
|
getCurrentTrace
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-A3WLV5VS.js";
|
|
27
27
|
import {
|
|
28
28
|
BITFAB_PROGRESS_PREFIX,
|
|
29
29
|
BitfabError,
|
|
30
30
|
reportReplayProgress
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-GT2GSQM2.js";
|
|
32
32
|
export {
|
|
33
33
|
BITFAB_PROGRESS_PREFIX,
|
|
34
34
|
Bitfab,
|
package/dist/node.cjs
CHANGED
|
@@ -331,14 +331,25 @@ function runWithReplayContext(ctx, fn) {
|
|
|
331
331
|
}
|
|
332
332
|
return fn();
|
|
333
333
|
}
|
|
334
|
-
var replayContextStorage, replayContextReady;
|
|
334
|
+
var replayContextStorage, REPLAY_CONTEXT_STORAGE_SYMBOL, replayContextReady;
|
|
335
335
|
var init_replayContext = __esm({
|
|
336
336
|
"src/replayContext.ts"() {
|
|
337
337
|
"use strict";
|
|
338
338
|
init_asyncStorage();
|
|
339
339
|
replayContextStorage = null;
|
|
340
|
+
REPLAY_CONTEXT_STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.replayContextStorage");
|
|
340
341
|
replayContextReady = asyncStorageReady.then(() => {
|
|
341
|
-
|
|
342
|
+
const shared = globalThis;
|
|
343
|
+
const existing = shared[REPLAY_CONTEXT_STORAGE_SYMBOL];
|
|
344
|
+
if (existing) {
|
|
345
|
+
replayContextStorage = existing;
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const created = createAsyncLocalStorage();
|
|
349
|
+
if (created) {
|
|
350
|
+
shared[REPLAY_CONTEXT_STORAGE_SYMBOL] = created;
|
|
351
|
+
replayContextStorage = created;
|
|
352
|
+
}
|
|
342
353
|
});
|
|
343
354
|
}
|
|
344
355
|
});
|
|
@@ -619,9 +630,10 @@ function buildMockTree(rootNode) {
|
|
|
619
630
|
}
|
|
620
631
|
return { spans };
|
|
621
632
|
}
|
|
622
|
-
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, includeDbBranchLease, adaptInputs) {
|
|
623
|
-
|
|
624
|
-
|
|
633
|
+
async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy, resolvedOverrides, replayedTraceId, includeDbBranchLease, dbBranchSettings, adaptInputs) {
|
|
634
|
+
let lease = includeDbBranchLease ? serverItem.dbBranchLease : void 0;
|
|
635
|
+
let leaseError = includeDbBranchLease ? serverItem.dbBranchLeaseError : void 0;
|
|
636
|
+
let dbSnapshotRef = serverItem.dbSnapshotRef;
|
|
625
637
|
let inputs = [];
|
|
626
638
|
let originalOutput;
|
|
627
639
|
let result;
|
|
@@ -630,6 +642,16 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
630
642
|
const originalTraceId = serverItem.originalTraceId ?? serverItem.sourceTraceId;
|
|
631
643
|
const originalSpanId = serverItem.originalSpanId ?? serverItem.sourceSpanId;
|
|
632
644
|
try {
|
|
645
|
+
if (includeDbBranchLease && !lease && !leaseError) {
|
|
646
|
+
const resolved = await httpClient.resolveDbBranchLease(
|
|
647
|
+
testRunId,
|
|
648
|
+
originalTraceId,
|
|
649
|
+
dbBranchSettings
|
|
650
|
+
);
|
|
651
|
+
lease = resolved.lease ?? void 0;
|
|
652
|
+
leaseError = resolved.leaseError ?? void 0;
|
|
653
|
+
dbSnapshotRef = resolved.dbSnapshotRef ?? dbSnapshotRef;
|
|
654
|
+
}
|
|
633
655
|
if (leaseError) {
|
|
634
656
|
throw new BitfabError(
|
|
635
657
|
`Replay requested a database branch for trace ${originalTraceId} but it could not be resolved (${leaseError.code}): ${leaseError.message}. The function was not run, because replaying it against the live database would produce a result that looks valid but did not use the historical data you asked for.`
|
|
@@ -741,7 +763,7 @@ async function processItem(httpClient, serverItem, fn, testRunId, mockStrategy,
|
|
|
741
763
|
// Null here (and on older servers) means "replay tokens not known".
|
|
742
764
|
tokens: null,
|
|
743
765
|
model: serverItem.model ?? null,
|
|
744
|
-
dbSnapshotRef:
|
|
766
|
+
dbSnapshotRef: dbSnapshotRef ?? null
|
|
745
767
|
};
|
|
746
768
|
}
|
|
747
769
|
async function mapWithConcurrency(tasks, maxConcurrency, onSettled) {
|
|
@@ -828,6 +850,7 @@ async function replay(httpClient, serviceUrl, traceFunctionKey, fn, options, reg
|
|
|
828
850
|
resolvedOverrides,
|
|
829
851
|
replayedTraceIds[index],
|
|
830
852
|
options?.dbBranch !== void 0,
|
|
853
|
+
resolveDbBranchSettings(options?.dbBranch),
|
|
831
854
|
options?.adaptInputs
|
|
832
855
|
)
|
|
833
856
|
);
|
|
@@ -1003,7 +1026,7 @@ registerAsyncLocalStorageClass(
|
|
|
1003
1026
|
);
|
|
1004
1027
|
|
|
1005
1028
|
// src/version.generated.ts
|
|
1006
|
-
var __version__ = "0.33.
|
|
1029
|
+
var __version__ = "0.33.2";
|
|
1007
1030
|
|
|
1008
1031
|
// src/constants.ts
|
|
1009
1032
|
var DEFAULT_SERVICE_URL = "https://bitfab.ai";
|
|
@@ -1021,6 +1044,7 @@ function unrefTimer(timer) {
|
|
|
1021
1044
|
|
|
1022
1045
|
// src/http.ts
|
|
1023
1046
|
init_warnOnce();
|
|
1047
|
+
var REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS = 3e5;
|
|
1024
1048
|
function serializePayloadBody(payload) {
|
|
1025
1049
|
try {
|
|
1026
1050
|
return { body: JSON.stringify(payload), dropped: [] };
|
|
@@ -1381,6 +1405,7 @@ var HttpClient = class {
|
|
|
1381
1405
|
}
|
|
1382
1406
|
if (includeDbBranchLease) {
|
|
1383
1407
|
payload.includeDbBranchLease = true;
|
|
1408
|
+
payload.lazyDbBranchLease = true;
|
|
1384
1409
|
}
|
|
1385
1410
|
if (experimentGroupId !== void 0) {
|
|
1386
1411
|
payload.experimentGroupId = experimentGroupId;
|
|
@@ -1394,7 +1419,7 @@ var HttpClient = class {
|
|
|
1394
1419
|
if (dbBranchSettings !== void 0) {
|
|
1395
1420
|
payload.dbBranchSettings = dbBranchSettings;
|
|
1396
1421
|
}
|
|
1397
|
-
const timeout = includeDbBranchLease ?
|
|
1422
|
+
const timeout = includeDbBranchLease ? REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS : 3e4;
|
|
1398
1423
|
return this.request("/api/sdk/replay/start", payload, {
|
|
1399
1424
|
timeout
|
|
1400
1425
|
});
|
|
@@ -1493,11 +1518,11 @@ var HttpClient = class {
|
|
|
1493
1518
|
* snapshot + preview branch and polls operations to readiness, which
|
|
1494
1519
|
* can take seconds.
|
|
1495
1520
|
*/
|
|
1496
|
-
async resolveDbBranchLease(testRunId, traceId,
|
|
1521
|
+
async resolveDbBranchLease(testRunId, traceId, dbBranchSettings) {
|
|
1497
1522
|
return this.request(
|
|
1498
1523
|
"/api/sdk/replay/resolveDbBranchLease",
|
|
1499
|
-
{ testRunId, traceId,
|
|
1500
|
-
{ timeout:
|
|
1524
|
+
{ testRunId, traceId, dbBranchSettings },
|
|
1525
|
+
{ timeout: REPLAY_DB_BRANCH_REQUEST_TIMEOUT_MS }
|
|
1501
1526
|
);
|
|
1502
1527
|
}
|
|
1503
1528
|
/** Release a previously-resolved DB branch by deleting its Neon branch. Idempotent server-side. */
|
|
@@ -3494,8 +3519,22 @@ init_warnOnce();
|
|
|
3494
3519
|
var activeTraceStates = /* @__PURE__ */ new Map();
|
|
3495
3520
|
var pendingSpanPromises = /* @__PURE__ */ new Map();
|
|
3496
3521
|
var asyncLocalStorage = null;
|
|
3522
|
+
var SPAN_CONTEXT_STORAGE_SYMBOL = /* @__PURE__ */ Symbol.for("bitfab.spanContextStorage");
|
|
3497
3523
|
var initializeAsyncContext = () => {
|
|
3498
|
-
|
|
3524
|
+
if (asyncLocalStorage) {
|
|
3525
|
+
return;
|
|
3526
|
+
}
|
|
3527
|
+
const shared = globalThis;
|
|
3528
|
+
const existing = shared[SPAN_CONTEXT_STORAGE_SYMBOL];
|
|
3529
|
+
if (existing) {
|
|
3530
|
+
asyncLocalStorage = existing;
|
|
3531
|
+
return;
|
|
3532
|
+
}
|
|
3533
|
+
const created = createAsyncLocalStorage();
|
|
3534
|
+
if (created) {
|
|
3535
|
+
shared[SPAN_CONTEXT_STORAGE_SYMBOL] = created;
|
|
3536
|
+
asyncLocalStorage = created;
|
|
3537
|
+
}
|
|
3499
3538
|
};
|
|
3500
3539
|
var asyncLocalStorageReady = asyncStorageReady.then(() => {
|
|
3501
3540
|
initializeAsyncContext();
|