@rasputin-ai/node 0.9.1 → 0.10.0
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/execution-recorder/automatic-runtime.d.ts.map +1 -1
- package/dist/execution-recorder/encode-frozen.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recorder-types.d.ts +7 -5
- package/dist/execution-recorder/execution-recorder-types.d.ts.map +1 -1
- package/dist/execution-recorder/execution-recorder.d.ts.map +1 -1
- package/dist/execution-recorder/recorder-memory-budget.d.ts +5 -2
- package/dist/execution-recorder/recorder-memory-budget.d.ts.map +1 -1
- package/dist/execution-recorder/runtime-state-size-budget.d.ts +1 -1
- package/dist/execution-recorder/runtime-state-size-budget.d.ts.map +1 -1
- package/dist/execution-recorder/safe-serialize.d.ts.map +1 -1
- package/dist/execution-recorder/value-freeze.d.ts +9 -4
- package/dist/execution-recorder/value-freeze.d.ts.map +1 -1
- package/dist/index.js +479 -622
- package/dist/instrument/bun.js +1 -1
- package/dist/instrument/node.js +1 -1
- package/dist/internal.js +476 -621
- package/dist/rasputin-init.d.ts.map +1 -1
- package/dist/sdk-meta.d.ts +1 -1
- package/dist/sdk-meta.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/execution-recorder/redact-keys.d.ts +0 -3
- package/dist/execution-recorder/redact-keys.d.ts.map +0 -1
package/dist/internal.js
CHANGED
|
@@ -130,7 +130,7 @@ import {
|
|
|
130
130
|
// ../recorder/src/run-exactly-once.ts
|
|
131
131
|
var runExactlyOnce = function __rasputinHandleRun__(invoke, callback) {
|
|
132
132
|
let outcome;
|
|
133
|
-
const wrapped = function
|
|
133
|
+
const wrapped = function __rasputinHandleRun__4() {
|
|
134
134
|
try {
|
|
135
135
|
const value = callback();
|
|
136
136
|
outcome = { kind: "value", value };
|
|
@@ -150,56 +150,19 @@ var runExactlyOnce = function __rasputinHandleRun__(invoke, callback) {
|
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
// ../recorder/src/call-handle.ts
|
|
153
|
-
var
|
|
153
|
+
var sharedPassthroughHandle = {
|
|
154
154
|
leave: (value) => value,
|
|
155
155
|
fail: () => {
|
|
156
156
|
},
|
|
157
157
|
end: () => {
|
|
158
158
|
},
|
|
159
|
-
run: function
|
|
159
|
+
run: function __rasputinHandleRun__2(callback) {
|
|
160
160
|
return runExactlyOnce((invoke) => invoke(), callback);
|
|
161
161
|
},
|
|
162
162
|
suspend: (value) => value,
|
|
163
163
|
resume: (value) => value
|
|
164
|
-
}
|
|
165
|
-
var
|
|
166
|
-
leave: (value) => {
|
|
167
|
-
try {
|
|
168
|
-
return handle.leave(value);
|
|
169
|
-
} catch {
|
|
170
|
-
return value;
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
fail: (error, liveArgs) => {
|
|
174
|
-
try {
|
|
175
|
-
handle.fail(error, liveArgs);
|
|
176
|
-
} catch {
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
end: () => {
|
|
180
|
-
try {
|
|
181
|
-
handle.end();
|
|
182
|
-
} catch {
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
run: function __rasputinHandleRun__3(callback) {
|
|
186
|
-
return runExactlyOnce((invoke) => handle.run(invoke), callback);
|
|
187
|
-
},
|
|
188
|
-
suspend: (value) => {
|
|
189
|
-
try {
|
|
190
|
-
return handle.suspend(value);
|
|
191
|
-
} catch {
|
|
192
|
-
return value;
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
resume: (value) => {
|
|
196
|
-
try {
|
|
197
|
-
return handle.resume(value);
|
|
198
|
-
} catch {
|
|
199
|
-
return value;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
});
|
|
164
|
+
};
|
|
165
|
+
var passthroughHandle = () => sharedPassthroughHandle;
|
|
203
166
|
|
|
204
167
|
// ../recorder/src/encoded-function-plan.ts
|
|
205
168
|
var encodedPlanOmitsCallValues = (plan) => plan[6] === 1;
|
|
@@ -672,7 +635,6 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
672
635
|
// src/execution-recorder/execution-recorder.ts
|
|
673
636
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
674
637
|
import {
|
|
675
|
-
createEnvSecretMatcher,
|
|
676
638
|
rasputinOmitted,
|
|
677
639
|
rasputinTagKind,
|
|
678
640
|
runtimeFunctionId as runtimeFunctionId2
|
|
@@ -1119,7 +1081,7 @@ var RecorderMemoryBudget = class {
|
|
|
1119
1081
|
}
|
|
1120
1082
|
return allocation;
|
|
1121
1083
|
}
|
|
1122
|
-
captureValue(allocation,
|
|
1084
|
+
captureValue(allocation, value, freeze) {
|
|
1123
1085
|
if (allocation.released) {
|
|
1124
1086
|
this.dropValues(allocation, 1);
|
|
1125
1087
|
return MEMORY_BUDGET_VALUE_MARKER;
|
|
@@ -1134,13 +1096,13 @@ var RecorderMemoryBudget = class {
|
|
|
1134
1096
|
this.dropValues(allocation, 1);
|
|
1135
1097
|
return MEMORY_BUDGET_VALUE_MARKER;
|
|
1136
1098
|
}
|
|
1137
|
-
const
|
|
1138
|
-
if (!this.reserve(allocation,
|
|
1099
|
+
const frozen = freeze(value);
|
|
1100
|
+
if (!this.reserve(allocation, frozen.estimatedBytes * VALUE_HEAP_ESTIMATE_MULTIPLIER)) {
|
|
1139
1101
|
this.markPressure(allocation, "structure-only");
|
|
1140
1102
|
this.dropValues(allocation, 1);
|
|
1141
1103
|
return MEMORY_BUDGET_VALUE_MARKER;
|
|
1142
1104
|
}
|
|
1143
|
-
return
|
|
1105
|
+
return frozen.value;
|
|
1144
1106
|
}
|
|
1145
1107
|
reserveCall(allocation, estimatedBytes) {
|
|
1146
1108
|
if (allocation.mode === "metadata-only") {
|
|
@@ -1224,7 +1186,16 @@ import {
|
|
|
1224
1186
|
} from "@rasputin-ai/core";
|
|
1225
1187
|
var MAX_RUNTIME_STATE_BYTES = 256 * 1024;
|
|
1226
1188
|
var VALUE_OMITTED_REASON = "runtime_state_size_budget";
|
|
1227
|
-
var
|
|
1189
|
+
var RUNTIME_STATE_ENCODED_BYTES = Symbol.for("rasputin.runtime_state_encoded_bytes");
|
|
1190
|
+
var encodedBytes = (state) => {
|
|
1191
|
+
const bytes = Buffer.byteLength(JSON.stringify(state), "utf8");
|
|
1192
|
+
Object.defineProperty(state, RUNTIME_STATE_ENCODED_BYTES, {
|
|
1193
|
+
value: bytes,
|
|
1194
|
+
enumerable: false,
|
|
1195
|
+
configurable: true
|
|
1196
|
+
});
|
|
1197
|
+
return bytes;
|
|
1198
|
+
};
|
|
1228
1199
|
var sizeMetadata = (originalBytes) => ({
|
|
1229
1200
|
reason: "runtime_state_size_budget",
|
|
1230
1201
|
originalBytes,
|
|
@@ -1390,51 +1361,12 @@ var enforceRuntimeStateSizeBudget = (input) => {
|
|
|
1390
1361
|
|
|
1391
1362
|
// src/execution-recorder/encode-frozen.ts
|
|
1392
1363
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
1393
|
-
import { RASPUTIN_REDACTED
|
|
1364
|
+
import { RASPUTIN_REDACTED } from "@rasputin-ai/core";
|
|
1394
1365
|
|
|
1395
1366
|
// src/execution-recorder/value-freeze.ts
|
|
1396
1367
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
1397
1368
|
import { types } from "node:util";
|
|
1398
|
-
import {
|
|
1399
|
-
MAX_ENV_SECRET_NEEDLE_LENGTH,
|
|
1400
|
-
RASPUTIN_REDACTED,
|
|
1401
|
-
RASPUTIN_WIRE_TAG
|
|
1402
|
-
} from "@rasputin-ai/core";
|
|
1403
|
-
|
|
1404
|
-
// src/execution-recorder/redact-keys.ts
|
|
1405
|
-
import { defaultSensitivePropertyNames, propertyNameIsSensitive } from "@rasputin-ai/core";
|
|
1406
|
-
var compactKey = (key) => {
|
|
1407
|
-
let compacted = "";
|
|
1408
|
-
for (let index = 0; index < key.length; index++) {
|
|
1409
|
-
const code = key.charCodeAt(index);
|
|
1410
|
-
if (code === 45 || code === 46 || code === 95) continue;
|
|
1411
|
-
compacted += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : key[index];
|
|
1412
|
-
}
|
|
1413
|
-
return compacted;
|
|
1414
|
-
};
|
|
1415
|
-
var stripTrailingDigits = (value) => {
|
|
1416
|
-
let end = value.length;
|
|
1417
|
-
while (end > 0) {
|
|
1418
|
-
const code = value.charCodeAt(end - 1);
|
|
1419
|
-
if (code < 48 || code > 57) break;
|
|
1420
|
-
end--;
|
|
1421
|
-
}
|
|
1422
|
-
return end === 0 ? value : value.slice(0, end);
|
|
1423
|
-
};
|
|
1424
|
-
var normalizeKey = (key) => stripTrailingDigits(compactKey(key));
|
|
1425
|
-
var compileRedactKeys = (extra) => {
|
|
1426
|
-
if (!extra?.length) return defaultSensitivePropertyNames();
|
|
1427
|
-
return /* @__PURE__ */ new Set([...defaultSensitivePropertyNames(), ...extra.map(normalizeKey)]);
|
|
1428
|
-
};
|
|
1429
|
-
var keyIsRedacted = (key, redactKeys) => {
|
|
1430
|
-
if (propertyNameIsSensitive(key)) return true;
|
|
1431
|
-
if (redactKeys.has(key)) return true;
|
|
1432
|
-
const compacted = compactKey(key);
|
|
1433
|
-
if (redactKeys.has(compacted)) return true;
|
|
1434
|
-
return redactKeys.has(stripTrailingDigits(compacted));
|
|
1435
|
-
};
|
|
1436
|
-
|
|
1437
|
-
// src/execution-recorder/value-freeze.ts
|
|
1369
|
+
import { RASPUTIN_WIRE_TAG } from "@rasputin-ai/core";
|
|
1438
1370
|
var defaults = {
|
|
1439
1371
|
maxDepth: 3,
|
|
1440
1372
|
maxObjectKeys: 30,
|
|
@@ -1462,16 +1394,20 @@ var atom = (kind, extra = {}) => ({
|
|
|
1462
1394
|
[FROZEN]: kind,
|
|
1463
1395
|
...extra
|
|
1464
1396
|
});
|
|
1465
|
-
var
|
|
1397
|
+
var NO_DATA = Symbol("rasputin.no-data");
|
|
1398
|
+
var ownValue = (value, key) => {
|
|
1466
1399
|
try {
|
|
1467
1400
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
1468
|
-
if (
|
|
1469
|
-
|
|
1470
|
-
return void 0;
|
|
1401
|
+
if (descriptor && "value" in descriptor) return descriptor.value;
|
|
1402
|
+
return NO_DATA;
|
|
1471
1403
|
} catch {
|
|
1472
|
-
return
|
|
1404
|
+
return NO_DATA;
|
|
1473
1405
|
}
|
|
1474
1406
|
};
|
|
1407
|
+
var copyBoundedString = (value) => {
|
|
1408
|
+
if (value.length === 0) return value;
|
|
1409
|
+
return Buffer2.from(value, "utf16le").toString("utf16le");
|
|
1410
|
+
};
|
|
1475
1411
|
var nativeErrorStackGet = (() => {
|
|
1476
1412
|
try {
|
|
1477
1413
|
return Object.getOwnPropertyDescriptor(Error.prototype, "stack")?.get;
|
|
@@ -1527,8 +1463,8 @@ var isDomException = (value) => {
|
|
|
1527
1463
|
}
|
|
1528
1464
|
};
|
|
1529
1465
|
var functionNameOf = (value) => {
|
|
1530
|
-
const
|
|
1531
|
-
if (
|
|
1466
|
+
const name = ownValue(value, "name");
|
|
1467
|
+
if (typeof name === "string" && name.length > 0) return name;
|
|
1532
1468
|
return "anonymous";
|
|
1533
1469
|
};
|
|
1534
1470
|
var errorNameOf = (value) => {
|
|
@@ -1541,8 +1477,8 @@ var errorNameOf = (value) => {
|
|
|
1541
1477
|
}
|
|
1542
1478
|
let current = value;
|
|
1543
1479
|
while (current) {
|
|
1544
|
-
const
|
|
1545
|
-
if (
|
|
1480
|
+
const name = ownValue(current, "name");
|
|
1481
|
+
if (typeof name === "string" && name.length > 0) return name;
|
|
1546
1482
|
try {
|
|
1547
1483
|
current = Object.getPrototypeOf(current);
|
|
1548
1484
|
} catch {
|
|
@@ -1558,8 +1494,8 @@ var errorMessageOf = (value) => {
|
|
|
1558
1494
|
} catch {
|
|
1559
1495
|
}
|
|
1560
1496
|
}
|
|
1561
|
-
const
|
|
1562
|
-
if (
|
|
1497
|
+
const message = ownValue(value, "message");
|
|
1498
|
+
if (message !== NO_DATA) return message;
|
|
1563
1499
|
if (!nativeErrorMessageGet) return void 0;
|
|
1564
1500
|
try {
|
|
1565
1501
|
return nativeErrorMessageGet.call(value);
|
|
@@ -1568,8 +1504,8 @@ var errorMessageOf = (value) => {
|
|
|
1568
1504
|
}
|
|
1569
1505
|
};
|
|
1570
1506
|
var errorStackOf = (value) => withoutPrepareStackTrace(() => {
|
|
1571
|
-
const
|
|
1572
|
-
if (
|
|
1507
|
+
const ownStack = ownValue(value, "stack");
|
|
1508
|
+
if (typeof ownStack === "string" && ownStack.length > 0) return ownStack;
|
|
1573
1509
|
try {
|
|
1574
1510
|
const getter = Object.getOwnPropertyDescriptor(value, "stack")?.get;
|
|
1575
1511
|
if (getter && nativeInstanceStackGet && getter === nativeInstanceStackGet) {
|
|
@@ -1629,24 +1565,23 @@ var sampleBytes = (bytes, max) => {
|
|
|
1629
1565
|
for (let index = 0; index < length; index++) sample[index] = bytes[index] ?? 0;
|
|
1630
1566
|
return sample;
|
|
1631
1567
|
};
|
|
1632
|
-
var
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
"
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
var assignFrozenField = (fields, key, value) => {
|
|
1642
|
-
if (RESERVED_USER_KEYS.has(key) || key.startsWith("__rasputin_")) {
|
|
1643
|
-
const escaped = fields.__rasputin_fields ?? [];
|
|
1644
|
-
escaped.push({ name: key, value });
|
|
1645
|
-
fields.__rasputin_fields = escaped;
|
|
1646
|
-
return;
|
|
1568
|
+
var KEY_META_CAP = 1024;
|
|
1569
|
+
var KEY_META_MAX_CHARS = 256;
|
|
1570
|
+
var keyMetaCache = /* @__PURE__ */ new Map();
|
|
1571
|
+
var keyMeta = (key) => {
|
|
1572
|
+
const cached = keyMetaCache.get(key);
|
|
1573
|
+
if (cached) return cached;
|
|
1574
|
+
const meta = { utf8Bytes: Buffer2.byteLength(key, "utf8") };
|
|
1575
|
+
if (key.length <= KEY_META_MAX_CHARS && keyMetaCache.size < KEY_META_CAP) {
|
|
1576
|
+
keyMetaCache.set(key, meta);
|
|
1647
1577
|
}
|
|
1648
|
-
|
|
1578
|
+
return meta;
|
|
1649
1579
|
};
|
|
1580
|
+
var frozenRecord = (keys, values) => ({
|
|
1581
|
+
[FROZEN]: "record",
|
|
1582
|
+
keys,
|
|
1583
|
+
values
|
|
1584
|
+
});
|
|
1650
1585
|
var ownEnumerableKeys = (value, maxKeys) => {
|
|
1651
1586
|
const keys = [];
|
|
1652
1587
|
let proto = null;
|
|
@@ -1676,97 +1611,8 @@ var bufferByteLength = (value) => {
|
|
|
1676
1611
|
}
|
|
1677
1612
|
};
|
|
1678
1613
|
var stringEstimate = (value) => NODE + 2 + Buffer2.byteLength(value, "utf8");
|
|
1679
|
-
var URL_LIKE_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1680
|
-
"url",
|
|
1681
|
-
"href",
|
|
1682
|
-
"originalurl",
|
|
1683
|
-
"path",
|
|
1684
|
-
"pathname",
|
|
1685
|
-
"search",
|
|
1686
|
-
"query",
|
|
1687
|
-
"requesturl",
|
|
1688
|
-
"requesturi",
|
|
1689
|
-
"location",
|
|
1690
|
-
"referer",
|
|
1691
|
-
"referrer",
|
|
1692
|
-
"uri",
|
|
1693
|
-
"connectionuri",
|
|
1694
|
-
"connectionurl",
|
|
1695
|
-
"databaseuri",
|
|
1696
|
-
"databaseurl",
|
|
1697
|
-
"mongouri",
|
|
1698
|
-
"mongourl",
|
|
1699
|
-
"redisuri",
|
|
1700
|
-
"redisurl",
|
|
1701
|
-
"postgresuri",
|
|
1702
|
-
"postgresurl"
|
|
1703
|
-
]);
|
|
1704
|
-
var compactPropertyName = (key) => {
|
|
1705
|
-
let compacted = "";
|
|
1706
|
-
for (let index = 0; index < key.length; index++) {
|
|
1707
|
-
const code = key.charCodeAt(index);
|
|
1708
|
-
if (code === 45 || code === 46 || code === 95) continue;
|
|
1709
|
-
compacted += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : key[index];
|
|
1710
|
-
}
|
|
1711
|
-
return compacted;
|
|
1712
|
-
};
|
|
1713
|
-
var propertyNameLooksLikeUrl = (key) => URL_LIKE_PROPERTY_NAMES.has(compactPropertyName(key));
|
|
1714
|
-
var looksLikeBareQueryString = (text) => {
|
|
1715
|
-
if (!text.includes("=") || /\s/.test(text)) return false;
|
|
1716
|
-
if (/^[a-z][a-z0-9+.-]*:/i.test(text) || text.startsWith("/")) return false;
|
|
1717
|
-
return /^[^\s=]+=[^\s]*(&[^\s=]+=[^\s]*)*$/.test(text);
|
|
1718
|
-
};
|
|
1719
|
-
var redactSensitiveQuery = (text, redactKeys) => {
|
|
1720
|
-
const queryAt = text.indexOf("?");
|
|
1721
|
-
let prefix = "";
|
|
1722
|
-
let query = "";
|
|
1723
|
-
let suffix = "";
|
|
1724
|
-
if (queryAt >= 0) {
|
|
1725
|
-
if (queryAt === text.length - 1) return text;
|
|
1726
|
-
const hashAt = text.indexOf("#", queryAt + 1);
|
|
1727
|
-
prefix = text.slice(0, queryAt + 1);
|
|
1728
|
-
query = hashAt < 0 ? text.slice(queryAt + 1) : text.slice(queryAt + 1, hashAt);
|
|
1729
|
-
suffix = hashAt < 0 ? "" : text.slice(hashAt);
|
|
1730
|
-
} else if (looksLikeBareQueryString(text)) {
|
|
1731
|
-
query = text;
|
|
1732
|
-
} else {
|
|
1733
|
-
return text;
|
|
1734
|
-
}
|
|
1735
|
-
if (!query.includes("=")) return text;
|
|
1736
|
-
let changed = false;
|
|
1737
|
-
const next = query.split("&").map((part) => {
|
|
1738
|
-
const equals = part.indexOf("=");
|
|
1739
|
-
const rawKey = equals < 0 ? part : part.slice(0, equals);
|
|
1740
|
-
if (!rawKey) return part;
|
|
1741
|
-
let decoded = rawKey;
|
|
1742
|
-
try {
|
|
1743
|
-
decoded = decodeURIComponent(rawKey.replace(/\+/g, " "));
|
|
1744
|
-
} catch {
|
|
1745
|
-
decoded = rawKey;
|
|
1746
|
-
}
|
|
1747
|
-
if (!keyIsRedacted(decoded, redactKeys) && !keyIsRedacted(rawKey, redactKeys)) return part;
|
|
1748
|
-
changed = true;
|
|
1749
|
-
return `${rawKey}=${RASPUTIN_REDACTED}`;
|
|
1750
|
-
});
|
|
1751
|
-
if (!changed) return text;
|
|
1752
|
-
return `${prefix}${next.join("&")}${suffix}`;
|
|
1753
|
-
};
|
|
1754
|
-
var redactUrlUserinfo = (text) => {
|
|
1755
|
-
const schemeEnd = text.indexOf("://");
|
|
1756
|
-
if (schemeEnd <= 0) return text;
|
|
1757
|
-
const rest = text.slice(schemeEnd + 3);
|
|
1758
|
-
let authorityEnd = rest.length;
|
|
1759
|
-
for (const marker of ["/", "?", "#"]) {
|
|
1760
|
-
const at = rest.indexOf(marker);
|
|
1761
|
-
if (at >= 0 && at < authorityEnd) authorityEnd = at;
|
|
1762
|
-
}
|
|
1763
|
-
const authority = rest.slice(0, authorityEnd);
|
|
1764
|
-
const userinfoEnd = authority.lastIndexOf("@");
|
|
1765
|
-
if (userinfoEnd < 0) return text;
|
|
1766
|
-
return `${text.slice(0, schemeEnd + 3)}${RASPUTIN_REDACTED}@${authority.slice(userinfoEnd + 1)}${rest.slice(authorityEnd)}`;
|
|
1767
|
-
};
|
|
1768
|
-
var redactUrlLikeString = (text, redactKeys) => redactSensitiveQuery(redactUrlUserinfo(text), redactKeys);
|
|
1769
1614
|
var isFrozenAtom = (value) => typeof value === "object" && value !== null && FROZEN in value;
|
|
1615
|
+
var isFrozenRecord = (value) => isFrozenAtom(value) && value[FROZEN] === "record";
|
|
1770
1616
|
var isRetainedOverflowChild = (value) => {
|
|
1771
1617
|
if (isFrozenAtom(value)) {
|
|
1772
1618
|
if (value[FROZEN] === "truncated") return true;
|
|
@@ -1784,16 +1630,13 @@ var keepOverflowChild = (child, overflowedOnChild) => {
|
|
|
1784
1630
|
var BYTE_LIMIT = "max_serialized_value_bytes";
|
|
1785
1631
|
var createValueFreezer = (options = {}) => {
|
|
1786
1632
|
const limits = compileFreezeLimits(options);
|
|
1787
|
-
const redactKeys = compileRedactKeys(options.redactKeys);
|
|
1788
|
-
const redactSecretValues = options.redactSecretValues;
|
|
1789
1633
|
const sharedPath = /* @__PURE__ */ new Set();
|
|
1790
1634
|
let freezing = false;
|
|
1791
1635
|
const add = (metrics, count) => {
|
|
1792
1636
|
metrics.estimatedBytes += count;
|
|
1793
1637
|
if (metrics.estimatedBytes > limits.maxSerializedValueBytes) metrics.oversize = true;
|
|
1794
1638
|
};
|
|
1795
|
-
const
|
|
1796
|
-
if (metrics.oversize) return void 0;
|
|
1639
|
+
const freezeLeaf = (value, metrics) => {
|
|
1797
1640
|
metrics.visitedNodes++;
|
|
1798
1641
|
if (value === null) {
|
|
1799
1642
|
add(metrics, 4);
|
|
@@ -1813,16 +1656,11 @@ var createValueFreezer = (options = {}) => {
|
|
|
1813
1656
|
return value;
|
|
1814
1657
|
}
|
|
1815
1658
|
if (typeof value === "string") {
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
text = redactSecretValues(value.length > cap ? value.slice(0, cap) : value);
|
|
1820
|
-
}
|
|
1821
|
-
if (text.length <= limits.maxStringLength) {
|
|
1822
|
-
add(metrics, stringEstimate(text));
|
|
1823
|
-
return text;
|
|
1659
|
+
if (value.length <= limits.maxStringLength) {
|
|
1660
|
+
add(metrics, stringEstimate(value));
|
|
1661
|
+
return value;
|
|
1824
1662
|
}
|
|
1825
|
-
const sliced =
|
|
1663
|
+
const sliced = copyBoundedString(value.slice(0, limits.maxStringLength));
|
|
1826
1664
|
add(metrics, NODE + stringEstimate(sliced) + 48);
|
|
1827
1665
|
return atom("truncated", {
|
|
1828
1666
|
reason: "max_string_length",
|
|
@@ -1853,10 +1691,13 @@ var createValueFreezer = (options = {}) => {
|
|
|
1853
1691
|
add(metrics, NODE + stringEstimate(name));
|
|
1854
1692
|
return atom("function", { value: name });
|
|
1855
1693
|
}
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1694
|
+
add(metrics, NODE + 16);
|
|
1695
|
+
return atom("unserializable");
|
|
1696
|
+
};
|
|
1697
|
+
const freezeInner = (value, depth, path, metrics) => {
|
|
1698
|
+
if (metrics.oversize) return void 0;
|
|
1699
|
+
if (value === null || typeof value !== "object") return freezeLeaf(value, metrics);
|
|
1700
|
+
metrics.visitedNodes++;
|
|
1860
1701
|
if (path.has(value)) {
|
|
1861
1702
|
add(metrics, NODE + 16);
|
|
1862
1703
|
return atom("circular");
|
|
@@ -1885,9 +1726,9 @@ var createValueFreezer = (options = {}) => {
|
|
|
1885
1726
|
const stack = errorStackOf(value);
|
|
1886
1727
|
const extras = {};
|
|
1887
1728
|
for (const key of ["code", "cause", "statusCode"]) {
|
|
1888
|
-
const
|
|
1889
|
-
if (
|
|
1890
|
-
extras[key] = freezeInner(
|
|
1729
|
+
const extra = ownValue(value, key);
|
|
1730
|
+
if (extra === NO_DATA) continue;
|
|
1731
|
+
extras[key] = freezeInner(extra, depth + 1, path, metrics);
|
|
1891
1732
|
}
|
|
1892
1733
|
return atom("Error", {
|
|
1893
1734
|
name,
|
|
@@ -1921,20 +1762,14 @@ var createValueFreezer = (options = {}) => {
|
|
|
1921
1762
|
if (counted2 >= limits.maxArrayElements || metrics.oversize) break;
|
|
1922
1763
|
const key = freezeInner(mapKey, depth + 1, path, metrics);
|
|
1923
1764
|
if (!keepOverflowChild(key, metrics.oversize)) break;
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
path,
|
|
1933
|
-
metrics
|
|
1934
|
-
);
|
|
1935
|
-
if (!keepOverflowChild(mapValue, metrics.oversize)) break;
|
|
1936
|
-
entries.push([key, mapValue]);
|
|
1937
|
-
}
|
|
1765
|
+
const mapValue = freezeInner(
|
|
1766
|
+
Map.prototype.get.call(value, mapKey),
|
|
1767
|
+
depth + 1,
|
|
1768
|
+
path,
|
|
1769
|
+
metrics
|
|
1770
|
+
);
|
|
1771
|
+
if (!keepOverflowChild(mapValue, metrics.oversize)) break;
|
|
1772
|
+
entries.push([key, mapValue]);
|
|
1938
1773
|
counted2++;
|
|
1939
1774
|
}
|
|
1940
1775
|
const hitBytes2 = metrics.oversize && counted2 < Math.min(size, limits.maxArrayElements);
|
|
@@ -1976,7 +1811,6 @@ var createValueFreezer = (options = {}) => {
|
|
|
1976
1811
|
add(metrics, 2);
|
|
1977
1812
|
const items = [];
|
|
1978
1813
|
const maxItems = value.length > limits.maxArrayElements ? limits.maxArrayElements - 1 : value.length;
|
|
1979
|
-
let redactNext = false;
|
|
1980
1814
|
for (let index = 0; index < maxItems; index++) {
|
|
1981
1815
|
if (metrics.oversize) break;
|
|
1982
1816
|
let descriptor;
|
|
@@ -1989,27 +1823,17 @@ var createValueFreezer = (options = {}) => {
|
|
|
1989
1823
|
add(metrics, NODE + 16);
|
|
1990
1824
|
if (metrics.oversize) break;
|
|
1991
1825
|
items.push(atom("hole"));
|
|
1992
|
-
redactNext = false;
|
|
1993
1826
|
continue;
|
|
1994
1827
|
}
|
|
1995
1828
|
if (!("value" in descriptor)) {
|
|
1996
1829
|
add(metrics, NODE + 16);
|
|
1997
1830
|
if (metrics.oversize) break;
|
|
1998
1831
|
items.push(atom("accessor"));
|
|
1999
|
-
redactNext = false;
|
|
2000
1832
|
continue;
|
|
2001
1833
|
}
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
items.push(RASPUTIN_REDACTED);
|
|
2006
|
-
redactNext = false;
|
|
2007
|
-
} else {
|
|
2008
|
-
const frozen = freezeInner(descriptor.value, depth + 1, path, metrics);
|
|
2009
|
-
if (!keepOverflowChild(frozen, metrics.oversize)) break;
|
|
2010
|
-
items.push(frozen);
|
|
2011
|
-
redactNext = typeof descriptor.value === "string" && keyIsRedacted(descriptor.value, redactKeys);
|
|
2012
|
-
}
|
|
1834
|
+
const frozen = freezeInner(descriptor.value, depth + 1, path, metrics);
|
|
1835
|
+
if (!keepOverflowChild(frozen, metrics.oversize)) break;
|
|
1836
|
+
items.push(frozen);
|
|
2013
1837
|
}
|
|
2014
1838
|
if (metrics.oversize && items.length < maxItems) {
|
|
2015
1839
|
add(metrics, NODE + 32);
|
|
@@ -2100,7 +1924,8 @@ var createValueFreezer = (options = {}) => {
|
|
|
2100
1924
|
}
|
|
2101
1925
|
}
|
|
2102
1926
|
add(metrics, 2);
|
|
2103
|
-
const
|
|
1927
|
+
const recordKeys = [];
|
|
1928
|
+
const recordValues = [];
|
|
2104
1929
|
let typeName;
|
|
2105
1930
|
let prototype = null;
|
|
2106
1931
|
try {
|
|
@@ -2110,12 +1935,12 @@ var createValueFreezer = (options = {}) => {
|
|
|
2110
1935
|
}
|
|
2111
1936
|
if (prototype && types.isProxy(prototype)) {
|
|
2112
1937
|
add(metrics, NODE + 16);
|
|
2113
|
-
return atom("instance", { type: "Proxy", value:
|
|
1938
|
+
return atom("instance", { type: "Proxy", value: frozenRecord(recordKeys, recordValues) });
|
|
2114
1939
|
}
|
|
2115
1940
|
if (prototype && prototype !== Object.prototype) {
|
|
2116
1941
|
typeName = "instance";
|
|
2117
1942
|
if (!types.isProxy(prototype)) {
|
|
2118
|
-
const ctor =
|
|
1943
|
+
const ctor = ownValue(prototype, "constructor");
|
|
2119
1944
|
if (typeof ctor === "function") {
|
|
2120
1945
|
const name = functionNameOf(ctor);
|
|
2121
1946
|
if (name && name !== "anonymous") typeName = name;
|
|
@@ -2123,8 +1948,6 @@ var createValueFreezer = (options = {}) => {
|
|
|
2123
1948
|
}
|
|
2124
1949
|
add(metrics, NODE + stringEstimate(typeName));
|
|
2125
1950
|
}
|
|
2126
|
-
const pairLabel = ownData(value, "name") ?? ownData(value, "key");
|
|
2127
|
-
const pairIsSensitive = pairLabel !== void 0 && typeof pairLabel.value === "string" && keyIsRedacted(pairLabel.value, redactKeys);
|
|
2128
1951
|
const { keys, truncated } = ownEnumerableKeys(value, limits.maxObjectKeys);
|
|
2129
1952
|
const maxKeys = truncated ? Math.max(0, limits.maxObjectKeys - 1) : keys.length;
|
|
2130
1953
|
let kept = 0;
|
|
@@ -2132,40 +1955,35 @@ var createValueFreezer = (options = {}) => {
|
|
|
2132
1955
|
if (metrics.oversize) break;
|
|
2133
1956
|
const key = keys[index];
|
|
2134
1957
|
if (key === void 0) continue;
|
|
2135
|
-
add(metrics,
|
|
1958
|
+
add(metrics, NODE + 2 + keyMeta(key).utf8Bytes);
|
|
2136
1959
|
if (metrics.oversize) break;
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
assignFrozenField(fields, key, RASPUTIN_REDACTED);
|
|
2141
|
-
kept++;
|
|
2142
|
-
continue;
|
|
2143
|
-
}
|
|
2144
|
-
const slot = ownData(value, key);
|
|
2145
|
-
if (slot) {
|
|
2146
|
-
const field = typeof slot.value === "string" && propertyNameLooksLikeUrl(key) ? redactUrlLikeString(slot.value, redactKeys) : slot.value;
|
|
2147
|
-
const frozen = freezeInner(field, depth + 1, path, metrics);
|
|
1960
|
+
const slot = ownValue(value, key);
|
|
1961
|
+
if (slot !== NO_DATA) {
|
|
1962
|
+
const frozen = freezeInner(slot, depth + 1, path, metrics);
|
|
2148
1963
|
if (!keepOverflowChild(frozen, metrics.oversize)) break;
|
|
2149
|
-
|
|
1964
|
+
recordKeys.push(key);
|
|
1965
|
+
recordValues.push(frozen);
|
|
2150
1966
|
kept++;
|
|
2151
1967
|
} else {
|
|
2152
1968
|
add(metrics, NODE + 16);
|
|
2153
1969
|
if (metrics.oversize) break;
|
|
2154
|
-
|
|
1970
|
+
recordKeys.push(key);
|
|
1971
|
+
recordValues.push(atom("accessor"));
|
|
2155
1972
|
kept++;
|
|
2156
1973
|
}
|
|
2157
1974
|
}
|
|
1975
|
+
const record = frozenRecord(recordKeys, recordValues);
|
|
2158
1976
|
const hitBytes = metrics.oversize && kept < maxKeys;
|
|
2159
1977
|
if (hitBytes || truncated) {
|
|
2160
1978
|
return atom("instance", {
|
|
2161
1979
|
type: typeName,
|
|
2162
|
-
value:
|
|
1980
|
+
value: record,
|
|
2163
1981
|
truncated: true,
|
|
2164
1982
|
reason: hitBytes ? BYTE_LIMIT : "max_object_keys"
|
|
2165
1983
|
});
|
|
2166
1984
|
}
|
|
2167
|
-
if (typeName) return atom("instance", { type: typeName, value:
|
|
2168
|
-
return
|
|
1985
|
+
if (typeName) return atom("instance", { type: typeName, value: record });
|
|
1986
|
+
return record;
|
|
2169
1987
|
} catch (error) {
|
|
2170
1988
|
add(metrics, NODE + 32);
|
|
2171
1989
|
return atom("unserializable", {
|
|
@@ -2176,30 +1994,43 @@ var createValueFreezer = (options = {}) => {
|
|
|
2176
1994
|
}
|
|
2177
1995
|
};
|
|
2178
1996
|
const freeze = (value) => {
|
|
2179
|
-
const
|
|
1997
|
+
const snapshot = {
|
|
1998
|
+
value: void 0,
|
|
1999
|
+
estimatedBytes: 0,
|
|
2000
|
+
visitedNodes: 0,
|
|
2001
|
+
oversize: false
|
|
2002
|
+
};
|
|
2003
|
+
if (value === null || typeof value !== "object") {
|
|
2004
|
+
try {
|
|
2005
|
+
snapshot.value = freezeLeaf(value, snapshot);
|
|
2006
|
+
return snapshot;
|
|
2007
|
+
} catch {
|
|
2008
|
+
return {
|
|
2009
|
+
value: atom("unserializable"),
|
|
2010
|
+
estimatedBytes: NODE + 16,
|
|
2011
|
+
visitedNodes: Math.max(1, snapshot.visitedNodes),
|
|
2012
|
+
oversize: false
|
|
2013
|
+
};
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2180
2016
|
const reentrant = freezing;
|
|
2181
2017
|
const path = reentrant ? /* @__PURE__ */ new Set() : sharedPath;
|
|
2182
2018
|
if (!reentrant) {
|
|
2183
2019
|
freezing = true;
|
|
2184
|
-
sharedPath.clear();
|
|
2020
|
+
if (sharedPath.size !== 0) sharedPath.clear();
|
|
2185
2021
|
}
|
|
2186
2022
|
try {
|
|
2187
|
-
|
|
2188
|
-
return
|
|
2189
|
-
value: frozen,
|
|
2190
|
-
estimatedBytes: metrics.estimatedBytes,
|
|
2191
|
-
visitedNodes: metrics.visitedNodes,
|
|
2192
|
-
oversize: metrics.oversize
|
|
2193
|
-
};
|
|
2023
|
+
snapshot.value = freezeInner(value, 0, path, snapshot);
|
|
2024
|
+
return snapshot;
|
|
2194
2025
|
} catch {
|
|
2195
2026
|
return {
|
|
2196
2027
|
value: atom("unserializable"),
|
|
2197
2028
|
estimatedBytes: NODE + 16,
|
|
2198
|
-
visitedNodes: Math.max(1,
|
|
2029
|
+
visitedNodes: Math.max(1, snapshot.visitedNodes),
|
|
2199
2030
|
oversize: false
|
|
2200
2031
|
};
|
|
2201
2032
|
} finally {
|
|
2202
|
-
path.clear();
|
|
2033
|
+
if (path.size !== 0) path.clear();
|
|
2203
2034
|
if (!reentrant) freezing = false;
|
|
2204
2035
|
}
|
|
2205
2036
|
};
|
|
@@ -2265,7 +2096,7 @@ var jsonStringUtf8Bytes = (value) => {
|
|
|
2265
2096
|
}
|
|
2266
2097
|
return bytes;
|
|
2267
2098
|
};
|
|
2268
|
-
var
|
|
2099
|
+
var ownData = (value, key) => {
|
|
2269
2100
|
try {
|
|
2270
2101
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
2271
2102
|
if (descriptor && "value" in descriptor) return descriptor.value;
|
|
@@ -2287,11 +2118,12 @@ var jsonLiteralUtf8Bytes = (value) => {
|
|
|
2287
2118
|
case "string":
|
|
2288
2119
|
return jsonStringUtf8Bytes(value);
|
|
2289
2120
|
case "object": {
|
|
2121
|
+
if (isFrozenAtom(value)) return jsonLiteralUtf8Bytes(encodeFrozen(value));
|
|
2290
2122
|
if (Array.isArray(value)) {
|
|
2291
2123
|
let bytes2 = 2;
|
|
2292
2124
|
for (let index = 0; index < value.length; index++) {
|
|
2293
2125
|
if (index > 0) bytes2 += 1;
|
|
2294
|
-
bytes2 += jsonLiteralUtf8Bytes(
|
|
2126
|
+
bytes2 += jsonLiteralUtf8Bytes(ownData(value, index));
|
|
2295
2127
|
}
|
|
2296
2128
|
return bytes2;
|
|
2297
2129
|
}
|
|
@@ -2302,7 +2134,7 @@ var jsonLiteralUtf8Bytes = (value) => {
|
|
|
2302
2134
|
if (!first) bytes += 1;
|
|
2303
2135
|
first = false;
|
|
2304
2136
|
bytes += jsonStringUtf8Bytes(key) + 1;
|
|
2305
|
-
bytes += jsonLiteralUtf8Bytes(
|
|
2137
|
+
bytes += jsonLiteralUtf8Bytes(ownData(record, key));
|
|
2306
2138
|
}
|
|
2307
2139
|
return bytes;
|
|
2308
2140
|
}
|
|
@@ -2368,6 +2200,28 @@ var encodePlainObject = (value) => {
|
|
|
2368
2200
|
}
|
|
2369
2201
|
return encoded;
|
|
2370
2202
|
};
|
|
2203
|
+
var encodeRecord = (record) => {
|
|
2204
|
+
const encoded = /* @__PURE__ */ Object.create(null);
|
|
2205
|
+
const escaped = [];
|
|
2206
|
+
let fieldsAssigned = false;
|
|
2207
|
+
const keys = record.keys;
|
|
2208
|
+
const values = record.values;
|
|
2209
|
+
for (let index = 0; index < keys.length; index++) {
|
|
2210
|
+
const key = keys[index];
|
|
2211
|
+
if (key === void 0) continue;
|
|
2212
|
+
const encodedValue = encodeFrozen(values[index]);
|
|
2213
|
+
if (key === "__proto__" || RESERVED_WIRE_KEYS.has(key) || key.startsWith("__rasputin_")) {
|
|
2214
|
+
if (!fieldsAssigned) {
|
|
2215
|
+
encoded.__rasputin_fields = escaped;
|
|
2216
|
+
fieldsAssigned = true;
|
|
2217
|
+
}
|
|
2218
|
+
escaped.push({ name: key, value: encodedValue });
|
|
2219
|
+
continue;
|
|
2220
|
+
}
|
|
2221
|
+
encoded[key] = encodedValue;
|
|
2222
|
+
}
|
|
2223
|
+
return encoded;
|
|
2224
|
+
};
|
|
2371
2225
|
var encodeAtom = (frozen) => {
|
|
2372
2226
|
const kind = frozen[FROZEN];
|
|
2373
2227
|
switch (kind) {
|
|
@@ -2437,8 +2291,10 @@ var encodeAtom = (frozen) => {
|
|
|
2437
2291
|
...frozen.serializedBytes === void 0 ? {} : { __serialized_bytes: frozen.serializedBytes },
|
|
2438
2292
|
...frozen.value === void 0 ? {} : { value: encodeFrozen(frozen.value) }
|
|
2439
2293
|
});
|
|
2294
|
+
case "record":
|
|
2295
|
+
return encodeRecord(frozen);
|
|
2440
2296
|
case "instance": {
|
|
2441
|
-
const fields =
|
|
2297
|
+
const fields = encodeFrozen(frozen.value);
|
|
2442
2298
|
const encoded = /* @__PURE__ */ Object.create(null);
|
|
2443
2299
|
if (typeof fields === "object" && fields !== null && !Array.isArray(fields)) {
|
|
2444
2300
|
for (const key of Object.keys(fields)) {
|
|
@@ -2465,7 +2321,8 @@ var encodeAtom = (frozen) => {
|
|
|
2465
2321
|
}
|
|
2466
2322
|
};
|
|
2467
2323
|
var encodeFrozen = (value) => {
|
|
2468
|
-
if (value ===
|
|
2324
|
+
if (value === RASPUTIN_REDACTED) return RASPUTIN_REDACTED;
|
|
2325
|
+
if (isFrozenRecord(value)) return encodeRecord(value);
|
|
2469
2326
|
if (isFrozenAtom(value)) return encodeAtom(value);
|
|
2470
2327
|
if (Array.isArray(value)) {
|
|
2471
2328
|
const items = new Array(value.length);
|
|
@@ -2615,6 +2472,7 @@ var warnIfMissingAsyncContextFrame = () => {
|
|
|
2615
2472
|
var DEFAULT_MAX_ACTIVE_MEMORY_BYTES = 64 * 1024 * 1024;
|
|
2616
2473
|
var DEFAULT_MAX_EXECUTION_HOLD_MS = 6e4;
|
|
2617
2474
|
var DEFAULT_MAX_RETAINED_ERROR_RECORDINGS = 32;
|
|
2475
|
+
var EMPTY_ARGS = [];
|
|
2618
2476
|
var phaseTimingEnabled = process.env.RASPUTIN_RECORDER_PHASE_TIMING === "1";
|
|
2619
2477
|
var manualFunctionDefinition = (value) => {
|
|
2620
2478
|
const located = /^(.+):([^:@]+)@(\d+):(\d+)$/.exec(value);
|
|
@@ -2633,7 +2491,7 @@ var normalizeFunctionDefinition = (value) => typeof value === "string" ? manualF
|
|
|
2633
2491
|
var elapsedMs2 = (startedAtNs, endedAtNs = process.hrtime.bigint()) => Number(endedAtNs - startedAtNs) / 1e6;
|
|
2634
2492
|
var roundedMilliseconds2 = (nanoseconds) => Math.round(Number(nanoseconds) / 1e6 * 1e4) / 1e4;
|
|
2635
2493
|
var addRecorderTime = (recording, nanoseconds) => {
|
|
2636
|
-
if (
|
|
2494
|
+
if (!phaseTimingEnabled || nanoseconds <= 0n) return;
|
|
2637
2495
|
recording.inlineRecorderTimeNs += nanoseconds;
|
|
2638
2496
|
};
|
|
2639
2497
|
var mapArrayLike = (args, map) => {
|
|
@@ -2649,7 +2507,7 @@ var notifyObserver = (observer, value) => {
|
|
|
2649
2507
|
} catch {
|
|
2650
2508
|
}
|
|
2651
2509
|
};
|
|
2652
|
-
var observeRecordedCallback = function
|
|
2510
|
+
var observeRecordedCallback = function __rasputinHandleRun__3(recording, recorderStartedAtNs, callback, onReturn, onThrow) {
|
|
2653
2511
|
const callbackStartedAtNs = phaseTimingEnabled ? process.hrtime.bigint() : recorderStartedAtNs;
|
|
2654
2512
|
const recordExitWork = (callbackEndedAtNs) => {
|
|
2655
2513
|
if (!phaseTimingEnabled) return;
|
|
@@ -2802,11 +2660,7 @@ var createExecutionRecorder = (options) => {
|
|
|
2802
2660
|
maxActiveMemoryBytes,
|
|
2803
2661
|
options.maxSerializedValueBytes ?? 16 * 1024
|
|
2804
2662
|
);
|
|
2805
|
-
const
|
|
2806
|
-
const serializer = createSafeSerializer({
|
|
2807
|
-
...options,
|
|
2808
|
-
...envSecretMatcher.needleCount > 0 ? { redactSecretValues: envSecretMatcher.redact } : {}
|
|
2809
|
-
});
|
|
2663
|
+
const serializer = createSafeSerializer(options);
|
|
2810
2664
|
const excludesSource = createSourceExclusionMatcher(options.excludeSources);
|
|
2811
2665
|
const journalPool = new ExecutionJournalPool(maxEventsPerExecution);
|
|
2812
2666
|
const plansByRuntimeId = [];
|
|
@@ -2855,15 +2709,11 @@ var createExecutionRecorder = (options) => {
|
|
|
2855
2709
|
stats.serializedValues++;
|
|
2856
2710
|
stats.serializedValueNodes += frozen.visitedNodes;
|
|
2857
2711
|
stats.serializedValueBytes += frozen.estimatedBytes;
|
|
2858
|
-
return
|
|
2859
|
-
value: frozen.value,
|
|
2860
|
-
bytes: frozen.estimatedBytes,
|
|
2861
|
-
visitedNodes: frozen.visitedNodes
|
|
2862
|
-
};
|
|
2712
|
+
return frozen;
|
|
2863
2713
|
};
|
|
2864
2714
|
const captureValue = (recording, value) => {
|
|
2865
2715
|
try {
|
|
2866
|
-
return memoryBudget.captureValue(recording.memory,
|
|
2716
|
+
return memoryBudget.captureValue(recording.memory, value, freezeAndCount);
|
|
2867
2717
|
} catch {
|
|
2868
2718
|
return { __rasputin_type: "unserializable" };
|
|
2869
2719
|
}
|
|
@@ -3026,7 +2876,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3026
2876
|
version: 4,
|
|
3027
2877
|
captureProfile: resolveCaptureProfile(recording, events, truncated, capture),
|
|
3028
2878
|
executionId: recording.executionId,
|
|
3029
|
-
startedAt: recording.
|
|
2879
|
+
startedAt: new Date(recording.startedAtMs).toISOString(),
|
|
3030
2880
|
durationMs: elapsedMs2(recording.startedAtNs, endedAtNs),
|
|
3031
2881
|
recorder: { inlineWallTimeMs: 0 },
|
|
3032
2882
|
execution: {
|
|
@@ -3060,7 +2910,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3060
2910
|
if (recording.evidenceDiscarded) return;
|
|
3061
2911
|
recording.evidenceDiscarded = true;
|
|
3062
2912
|
recording.cachedState = void 0;
|
|
3063
|
-
recording.repeatedCalls =
|
|
2913
|
+
recording.repeatedCalls = void 0;
|
|
3064
2914
|
recording.lateCapturedCallIds = void 0;
|
|
3065
2915
|
recording.capturedErrors = /* @__PURE__ */ new WeakMap();
|
|
3066
2916
|
if (recording.journal) {
|
|
@@ -3246,11 +3096,15 @@ var createExecutionRecorder = (options) => {
|
|
|
3246
3096
|
countDroppedEvents(recording, droppedBefore);
|
|
3247
3097
|
};
|
|
3248
3098
|
const repeatedCallGroup = (recording, plan, parentCallId) => {
|
|
3249
|
-
|
|
3250
|
-
|
|
3099
|
+
let slots = recording.repeatedCalls;
|
|
3100
|
+
if (!slots) {
|
|
3101
|
+
slots = /* @__PURE__ */ new Map();
|
|
3102
|
+
recording.repeatedCalls = slots;
|
|
3103
|
+
}
|
|
3104
|
+
let slot = slots.get(plan.runtimePlanId);
|
|
3251
3105
|
if (!slot) {
|
|
3252
3106
|
slot = {};
|
|
3253
|
-
slots
|
|
3107
|
+
slots.set(plan.runtimePlanId, slot);
|
|
3254
3108
|
}
|
|
3255
3109
|
if (parentCallId === void 0) {
|
|
3256
3110
|
if (!slot.root) slot.root = newRepeatedGroup(plan);
|
|
@@ -3400,10 +3254,10 @@ var createExecutionRecorder = (options) => {
|
|
|
3400
3254
|
} catch {
|
|
3401
3255
|
}
|
|
3402
3256
|
};
|
|
3403
|
-
const runStore = function
|
|
3257
|
+
const runStore = function __rasputinHandleRun__4(store, callback) {
|
|
3404
3258
|
if (!phaseTimingEnabled) return storage.run(store, callback);
|
|
3405
3259
|
const alsStartedAtNs = process.hrtime.bigint();
|
|
3406
|
-
return storage.run(store, function
|
|
3260
|
+
return storage.run(store, function __rasputinHandleRun__5() {
|
|
3407
3261
|
addPhase("alsNs", process.hrtime.bigint() - alsStartedAtNs);
|
|
3408
3262
|
return callback();
|
|
3409
3263
|
});
|
|
@@ -3415,7 +3269,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3415
3269
|
const recording = {
|
|
3416
3270
|
executionId: `${Date.now()}-${process.pid}-${++executionCounter}`,
|
|
3417
3271
|
storageGeneration: ++storageClock,
|
|
3418
|
-
|
|
3272
|
+
startedAtMs: Date.now(),
|
|
3419
3273
|
startedAtNs: recorderStartedAtNs,
|
|
3420
3274
|
inlineRecorderTimeNs: 0n,
|
|
3421
3275
|
execution: {
|
|
@@ -3423,7 +3277,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3423
3277
|
...metadata.request ? { request: { ...metadata.request } } : {}
|
|
3424
3278
|
},
|
|
3425
3279
|
journal: void 0,
|
|
3426
|
-
repeatedCalls: [],
|
|
3427
3280
|
capturedErrors: /* @__PURE__ */ new WeakMap(),
|
|
3428
3281
|
nextCallId: 0,
|
|
3429
3282
|
inFlightCalls: 0,
|
|
@@ -3441,11 +3294,11 @@ var createExecutionRecorder = (options) => {
|
|
|
3441
3294
|
addRecorderTime(recording, process.hrtime.bigint() - recorderStartedAtNs);
|
|
3442
3295
|
const store = { recording };
|
|
3443
3296
|
return {
|
|
3444
|
-
run: function
|
|
3297
|
+
run: function __rasputinHandleRun__4(callback) {
|
|
3445
3298
|
let startedCallback = false;
|
|
3446
3299
|
try {
|
|
3447
3300
|
const runStartedAtNs = process.hrtime.bigint();
|
|
3448
|
-
return runStore(store, function
|
|
3301
|
+
return runStore(store, function __rasputinHandleRun__5() {
|
|
3449
3302
|
startedCallback = true;
|
|
3450
3303
|
addRecorderTime(recording, process.hrtime.bigint() - runStartedAtNs);
|
|
3451
3304
|
try {
|
|
@@ -3493,14 +3346,14 @@ var createExecutionRecorder = (options) => {
|
|
|
3493
3346
|
return void 0;
|
|
3494
3347
|
}
|
|
3495
3348
|
};
|
|
3496
|
-
const runPreparedFunctionFromStore = function
|
|
3349
|
+
const runPreparedFunctionFromStore = function __rasputinHandleRun__4(store, plan, args, callback, omitValues) {
|
|
3497
3350
|
let startedCallback = false;
|
|
3498
3351
|
try {
|
|
3499
3352
|
return runPreparedFunctionFromStoreInner(
|
|
3500
3353
|
store,
|
|
3501
3354
|
plan,
|
|
3502
3355
|
args,
|
|
3503
|
-
function
|
|
3356
|
+
function __rasputinHandleRun__5() {
|
|
3504
3357
|
startedCallback = true;
|
|
3505
3358
|
return callback();
|
|
3506
3359
|
},
|
|
@@ -3511,7 +3364,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3511
3364
|
return callback();
|
|
3512
3365
|
}
|
|
3513
3366
|
};
|
|
3514
|
-
const runPreparedFunctionFromStoreInner = function
|
|
3367
|
+
const runPreparedFunctionFromStoreInner = function __rasputinHandleRun__4(store, plan, args, callback, omitValues) {
|
|
3515
3368
|
const omitCallValues = omitValues === true || plan.omitCallValues;
|
|
3516
3369
|
if (!store) return callback();
|
|
3517
3370
|
if (plan.disabled) {
|
|
@@ -3532,7 +3385,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3532
3385
|
const recorderStartedAtNs = process.hrtime.bigint();
|
|
3533
3386
|
if (store.suppressCapture || plan.excluded) {
|
|
3534
3387
|
stats.functionCallsExcluded++;
|
|
3535
|
-
return runStore({ ...store, suppressCapture: true }, function
|
|
3388
|
+
return runStore({ ...store, suppressCapture: true }, function __rasputinHandleRun__5() {
|
|
3536
3389
|
addRecorderTime(store.recording, process.hrtime.bigint() - recorderStartedAtNs);
|
|
3537
3390
|
return callback();
|
|
3538
3391
|
});
|
|
@@ -3550,7 +3403,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3550
3403
|
if (group.observedCalls > maxCapturedCallsPerFunction) {
|
|
3551
3404
|
const startedAtNs2 = process.hrtime.bigint();
|
|
3552
3405
|
try {
|
|
3553
|
-
const result = runStore(store, function
|
|
3406
|
+
const result = runStore(store, function __rasputinHandleRun__5() {
|
|
3554
3407
|
return callback();
|
|
3555
3408
|
});
|
|
3556
3409
|
recordSuppressedCall(recording, group, parentCallId, startedAtNs2, process.hrtime.bigint());
|
|
@@ -3565,7 +3418,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3565
3418
|
const startedAtNs = process.hrtime.bigint();
|
|
3566
3419
|
if (!journal) {
|
|
3567
3420
|
memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
|
|
3568
|
-
return runStore(store, function
|
|
3421
|
+
return runStore(store, function __rasputinHandleRun__5() {
|
|
3569
3422
|
return observeRecordedCallback(
|
|
3570
3423
|
recording,
|
|
3571
3424
|
recorderStartedAtNs,
|
|
@@ -3584,7 +3437,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3584
3437
|
countDroppedEvents(recording, droppedBefore);
|
|
3585
3438
|
settleInFlight(recording);
|
|
3586
3439
|
};
|
|
3587
|
-
return runStore(store, function
|
|
3440
|
+
return runStore(store, function __rasputinHandleRun__5() {
|
|
3588
3441
|
return observeRecordedCallback(
|
|
3589
3442
|
recording,
|
|
3590
3443
|
recorderStartedAtNs,
|
|
@@ -3615,7 +3468,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3615
3468
|
journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
|
|
3616
3469
|
} catch {
|
|
3617
3470
|
journal.dropCall();
|
|
3618
|
-
return runStore(store, function
|
|
3471
|
+
return runStore(store, function __rasputinHandleRun__5() {
|
|
3619
3472
|
return observeRecordedCallback(
|
|
3620
3473
|
recording,
|
|
3621
3474
|
recorderStartedAtNs,
|
|
@@ -3628,17 +3481,22 @@ var createExecutionRecorder = (options) => {
|
|
|
3628
3481
|
});
|
|
3629
3482
|
}
|
|
3630
3483
|
const callStore = { recording, currentCallId: callId };
|
|
3631
|
-
return runStore(callStore, function
|
|
3484
|
+
return runStore(callStore, function __rasputinHandleRun__5() {
|
|
3632
3485
|
return observeRecordedCallback(
|
|
3633
3486
|
recording,
|
|
3634
3487
|
recorderStartedAtNs,
|
|
3635
3488
|
callback,
|
|
3636
3489
|
(value) => {
|
|
3637
3490
|
if (recording.journal) {
|
|
3638
|
-
const
|
|
3639
|
-
const durationNs = process.hrtime.bigint() - startedAtNs;
|
|
3491
|
+
const endedAtNs = process.hrtime.bigint();
|
|
3640
3492
|
const returnValue = omitCallValues ? rasputinOmitted() : captureValue(recording, value);
|
|
3641
|
-
recording.journal.finishCall(
|
|
3493
|
+
recording.journal.finishCall(
|
|
3494
|
+
KIND_EXIT,
|
|
3495
|
+
callId,
|
|
3496
|
+
endedAtNs - recording.startedAtNs,
|
|
3497
|
+
endedAtNs - startedAtNs,
|
|
3498
|
+
returnValue
|
|
3499
|
+
);
|
|
3642
3500
|
stats.functionCallsCaptured++;
|
|
3643
3501
|
}
|
|
3644
3502
|
settleInFlight(recording);
|
|
@@ -3649,11 +3507,12 @@ var createExecutionRecorder = (options) => {
|
|
|
3649
3507
|
return;
|
|
3650
3508
|
}
|
|
3651
3509
|
const capturedError = serializedError(recording, error, callId);
|
|
3510
|
+
const endedAtNs = process.hrtime.bigint();
|
|
3652
3511
|
recording.journal.finishCall(
|
|
3653
3512
|
KIND_THROW,
|
|
3654
3513
|
callId,
|
|
3655
|
-
|
|
3656
|
-
|
|
3514
|
+
endedAtNs - recording.startedAtNs,
|
|
3515
|
+
endedAtNs - startedAtNs,
|
|
3657
3516
|
capturedError.value
|
|
3658
3517
|
);
|
|
3659
3518
|
stats.functionCallsCaptured++;
|
|
@@ -3663,62 +3522,189 @@ var createExecutionRecorder = (options) => {
|
|
|
3663
3522
|
);
|
|
3664
3523
|
});
|
|
3665
3524
|
};
|
|
3666
|
-
const noopHandle2 =
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3525
|
+
const noopHandle2 = passthroughHandle();
|
|
3526
|
+
class CallFrame {
|
|
3527
|
+
constructor(mode, recording, parentStore, activeStore, plan, args, omitCallValues, parentCallId, startedAtNs, callId, group, captureDroppedThrow) {
|
|
3528
|
+
this.mode = mode;
|
|
3529
|
+
this.status = "open";
|
|
3530
|
+
this.pendingReturn = void 0;
|
|
3531
|
+
this.ended = false;
|
|
3532
|
+
this.suspended = false;
|
|
3533
|
+
this.startedAtNs = startedAtNs;
|
|
3534
|
+
this.callId = callId;
|
|
3535
|
+
this.recording = recording;
|
|
3536
|
+
this.plan = plan;
|
|
3537
|
+
this.args = args;
|
|
3538
|
+
this.omitCallValues = omitCallValues;
|
|
3539
|
+
this.parentCallId = parentCallId;
|
|
3540
|
+
this.parentStore = parentStore;
|
|
3541
|
+
this.activeStore = activeStore;
|
|
3542
|
+
this.group = group;
|
|
3543
|
+
this.captureDroppedThrow = captureDroppedThrow;
|
|
3544
|
+
}
|
|
3545
|
+
leave(value) {
|
|
3681
3546
|
try {
|
|
3682
|
-
|
|
3547
|
+
if (this.status !== "failed") {
|
|
3548
|
+
this.status = "left";
|
|
3549
|
+
this.pendingReturn = value;
|
|
3550
|
+
}
|
|
3551
|
+
return value;
|
|
3683
3552
|
} catch {
|
|
3684
|
-
|
|
3553
|
+
return value;
|
|
3685
3554
|
}
|
|
3686
|
-
}
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3555
|
+
}
|
|
3556
|
+
fail(error, liveArgs) {
|
|
3557
|
+
try {
|
|
3558
|
+
if (this.status === "failed") return;
|
|
3559
|
+
this.status = "failed";
|
|
3560
|
+
if (this.mode === "captured") writeCapturedThrow(this, error);
|
|
3561
|
+
else if (this.mode === "suppressed" && this.plan) {
|
|
3562
|
+
captureCompletedThrow(
|
|
3563
|
+
this.recording,
|
|
3564
|
+
this.plan,
|
|
3565
|
+
liveArgs ?? this.args,
|
|
3566
|
+
this.parentCallId,
|
|
3567
|
+
this.startedAtNs,
|
|
3568
|
+
error
|
|
3569
|
+
);
|
|
3570
|
+
} else if (this.mode === "dropped" && this.captureDroppedThrow && this.plan) {
|
|
3571
|
+
captureCompletedThrow(
|
|
3572
|
+
this.recording,
|
|
3573
|
+
this.plan,
|
|
3574
|
+
this.args,
|
|
3575
|
+
this.parentCallId,
|
|
3576
|
+
this.startedAtNs,
|
|
3577
|
+
error
|
|
3578
|
+
);
|
|
3579
|
+
}
|
|
3580
|
+
} catch {
|
|
3581
|
+
}
|
|
3582
|
+
}
|
|
3583
|
+
end() {
|
|
3584
|
+
if (this.mode === "expired") return;
|
|
3585
|
+
try {
|
|
3586
|
+
if (this.status !== "failed") {
|
|
3587
|
+
if (this.mode === "captured") {
|
|
3588
|
+
writeCapturedExit(this, this.status === "left" ? this.pendingReturn : void 0);
|
|
3589
|
+
} else if (this.mode === "suppressed" && this.group) {
|
|
3590
|
+
recordSuppressedCall(
|
|
3591
|
+
this.recording,
|
|
3592
|
+
this.group,
|
|
3593
|
+
this.parentCallId,
|
|
3594
|
+
this.startedAtNs,
|
|
3595
|
+
process.hrtime.bigint()
|
|
3596
|
+
);
|
|
3597
|
+
} else if (this.mode === "dropped") {
|
|
3598
|
+
const droppedBefore = this.recording.journal?.dropped ?? 0;
|
|
3599
|
+
this.recording.journal?.dropCall();
|
|
3600
|
+
countDroppedEvents(this.recording, droppedBefore);
|
|
3697
3601
|
}
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
}
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3602
|
+
}
|
|
3603
|
+
} catch {
|
|
3604
|
+
}
|
|
3605
|
+
try {
|
|
3606
|
+
if (this.ended) return;
|
|
3607
|
+
this.ended = true;
|
|
3608
|
+
if (this.mode !== "excluded") settleInFlight(this.recording);
|
|
3609
|
+
expectStore(this, this.activeStore);
|
|
3610
|
+
enterStore(this, this.parentStore);
|
|
3611
|
+
} catch {
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
run(callback) {
|
|
3615
|
+
if (this.mode === "expired") {
|
|
3616
|
+
return runExactlyOnce((invoke) => storage.run(this.activeStore, invoke), callback);
|
|
3617
|
+
}
|
|
3618
|
+
return runExactlyOnce((invoke) => {
|
|
3619
|
+
try {
|
|
3620
|
+
enterStore(this, this.parentStore);
|
|
3621
|
+
} catch {
|
|
3622
|
+
}
|
|
3623
|
+
return storage.run(this.activeStore, invoke);
|
|
3624
|
+
}, callback);
|
|
3625
|
+
}
|
|
3626
|
+
suspend(value) {
|
|
3627
|
+
if (this.mode === "expired") return value;
|
|
3628
|
+
try {
|
|
3629
|
+
expectStore(this, this.activeStore);
|
|
3630
|
+
this.suspended = true;
|
|
3631
|
+
enterStore(this, this.parentStore);
|
|
3705
3632
|
return value;
|
|
3706
|
-
}
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3633
|
+
} catch {
|
|
3634
|
+
return value;
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
resume(value) {
|
|
3638
|
+
if (this.mode === "expired") return value;
|
|
3639
|
+
try {
|
|
3640
|
+
if (this.suspended) {
|
|
3641
|
+
expectStore(this, this.parentStore);
|
|
3642
|
+
this.suspended = false;
|
|
3643
|
+
enterStore(this, this.activeStore);
|
|
3712
3644
|
} else {
|
|
3713
|
-
expectStore(
|
|
3645
|
+
expectStore(this, this.activeStore);
|
|
3714
3646
|
}
|
|
3715
3647
|
return value;
|
|
3716
|
-
}
|
|
3717
|
-
|
|
3718
|
-
expectStore(active);
|
|
3719
|
-
enter(parent);
|
|
3648
|
+
} catch {
|
|
3649
|
+
return value;
|
|
3720
3650
|
}
|
|
3721
|
-
}
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
const enterStore = (frame, next) => {
|
|
3654
|
+
if (currentStore() === next) return;
|
|
3655
|
+
try {
|
|
3656
|
+
storage.enterWith(next);
|
|
3657
|
+
} catch {
|
|
3658
|
+
if (frame.plan) degradeAttribution(frame.recording, frame.plan);
|
|
3659
|
+
}
|
|
3660
|
+
};
|
|
3661
|
+
const expectStore = (frame, expected) => {
|
|
3662
|
+
if (currentStore() !== expected && frame.plan) degradeAttribution(frame.recording, frame.plan);
|
|
3663
|
+
};
|
|
3664
|
+
const writeCapturedExit = (frame, value) => {
|
|
3665
|
+
if (!frame.recording.journal) return;
|
|
3666
|
+
const endedAtNs = process.hrtime.bigint();
|
|
3667
|
+
const returnValue = frame.omitCallValues ? rasputinOmitted() : captureValue(frame.recording, value);
|
|
3668
|
+
frame.recording.journal.finishCall(
|
|
3669
|
+
KIND_EXIT,
|
|
3670
|
+
frame.callId,
|
|
3671
|
+
endedAtNs - frame.recording.startedAtNs,
|
|
3672
|
+
endedAtNs - frame.startedAtNs,
|
|
3673
|
+
returnValue
|
|
3674
|
+
);
|
|
3675
|
+
stats.functionCallsCaptured++;
|
|
3676
|
+
};
|
|
3677
|
+
const writeCapturedThrow = (frame, error) => {
|
|
3678
|
+
if (!frame.recording.journal) return;
|
|
3679
|
+
const endedAtNs = process.hrtime.bigint();
|
|
3680
|
+
const capturedError = serializedError(frame.recording, error, frame.callId);
|
|
3681
|
+
frame.recording.journal.finishCall(
|
|
3682
|
+
KIND_THROW,
|
|
3683
|
+
frame.callId,
|
|
3684
|
+
endedAtNs - frame.recording.startedAtNs,
|
|
3685
|
+
endedAtNs - frame.startedAtNs,
|
|
3686
|
+
capturedError.value
|
|
3687
|
+
);
|
|
3688
|
+
stats.functionCallsCaptured++;
|
|
3689
|
+
capturedError.commit();
|
|
3690
|
+
};
|
|
3691
|
+
const activateUncaptured = (mode, recording, parentStore, plan, args, omitCallValues, parentCallId, startedAtNs, group, captureDroppedThrow) => {
|
|
3692
|
+
const frame = new CallFrame(
|
|
3693
|
+
mode,
|
|
3694
|
+
recording,
|
|
3695
|
+
parentStore,
|
|
3696
|
+
parentStore,
|
|
3697
|
+
plan,
|
|
3698
|
+
args,
|
|
3699
|
+
omitCallValues,
|
|
3700
|
+
parentCallId,
|
|
3701
|
+
startedAtNs,
|
|
3702
|
+
0,
|
|
3703
|
+
group,
|
|
3704
|
+
captureDroppedThrow
|
|
3705
|
+
);
|
|
3706
|
+
enterStore(frame, parentStore);
|
|
3707
|
+
return frame;
|
|
3722
3708
|
};
|
|
3723
3709
|
const enterPreparedFunctionFromStore = (store, plan, args, omitValues) => {
|
|
3724
3710
|
if (!store) return noopHandle2;
|
|
@@ -3728,20 +3714,21 @@ var createExecutionRecorder = (options) => {
|
|
|
3728
3714
|
}
|
|
3729
3715
|
if (store.recording.finished) {
|
|
3730
3716
|
if (!store.recording.budgetExpired && !store.recording.evicted) return noopHandle2;
|
|
3731
|
-
const
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3717
|
+
const expiredStore = { recording: store.recording };
|
|
3718
|
+
return new CallFrame(
|
|
3719
|
+
"expired",
|
|
3720
|
+
store.recording,
|
|
3721
|
+
expiredStore,
|
|
3722
|
+
expiredStore,
|
|
3723
|
+
void 0,
|
|
3724
|
+
EMPTY_ARGS,
|
|
3725
|
+
false,
|
|
3726
|
+
void 0,
|
|
3727
|
+
0n,
|
|
3728
|
+
0,
|
|
3729
|
+
void 0,
|
|
3730
|
+
false
|
|
3731
|
+
);
|
|
3745
3732
|
}
|
|
3746
3733
|
stats.functionCallsObserved++;
|
|
3747
3734
|
const recording = store.recording;
|
|
@@ -3750,22 +3737,22 @@ var createExecutionRecorder = (options) => {
|
|
|
3750
3737
|
if (store.suppressCapture || plan.excluded) {
|
|
3751
3738
|
stats.functionCallsExcluded++;
|
|
3752
3739
|
const excludedStore = { ...store, suppressCapture: true };
|
|
3753
|
-
const
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3740
|
+
const frame = new CallFrame(
|
|
3741
|
+
"excluded",
|
|
3742
|
+
recording,
|
|
3743
|
+
store,
|
|
3744
|
+
excludedStore,
|
|
3745
|
+
plan,
|
|
3746
|
+
EMPTY_ARGS,
|
|
3747
|
+
false,
|
|
3748
|
+
void 0,
|
|
3749
|
+
0n,
|
|
3750
|
+
0,
|
|
3751
|
+
void 0,
|
|
3752
|
+
false
|
|
3753
|
+
);
|
|
3754
|
+
enterStore(frame, excludedStore);
|
|
3755
|
+
return frame;
|
|
3769
3756
|
}
|
|
3770
3757
|
recording.inFlightCalls++;
|
|
3771
3758
|
const group = repeatedCallGroup(recording, plan, parentCallId);
|
|
@@ -3775,127 +3762,64 @@ var createExecutionRecorder = (options) => {
|
|
|
3775
3762
|
if (group.observedCalls === 1) journal?.notePlan(plan.runtimePlanId);
|
|
3776
3763
|
} catch {
|
|
3777
3764
|
}
|
|
3778
|
-
let status = "open";
|
|
3779
|
-
let pendingReturn;
|
|
3780
|
-
let ended = false;
|
|
3781
3765
|
const startedAtNs = process.hrtime.bigint();
|
|
3782
3766
|
const parentStore = store;
|
|
3783
|
-
const uncaptured = bindStoreTransitions(parentStore, parentStore, recording, plan);
|
|
3784
|
-
const finishEnd = () => {
|
|
3785
|
-
if (ended) return;
|
|
3786
|
-
ended = true;
|
|
3787
|
-
settleInFlight(recording);
|
|
3788
|
-
uncaptured.restore();
|
|
3789
|
-
};
|
|
3790
|
-
const context = {
|
|
3791
|
-
run: uncaptured.run,
|
|
3792
|
-
suspend: uncaptured.suspend,
|
|
3793
|
-
resume: uncaptured.resume
|
|
3794
|
-
};
|
|
3795
3767
|
if (group.observedCalls > maxCapturedCallsPerFunction) {
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
captureCompletedThrow(
|
|
3809
|
-
recording,
|
|
3810
|
-
plan,
|
|
3811
|
-
liveArgs ?? args,
|
|
3812
|
-
parentCallId,
|
|
3813
|
-
startedAtNs,
|
|
3814
|
-
error
|
|
3815
|
-
);
|
|
3816
|
-
},
|
|
3817
|
-
end: () => {
|
|
3818
|
-
if (status !== "failed") {
|
|
3819
|
-
recordSuppressedCall(
|
|
3820
|
-
recording,
|
|
3821
|
-
group,
|
|
3822
|
-
parentCallId,
|
|
3823
|
-
startedAtNs,
|
|
3824
|
-
process.hrtime.bigint()
|
|
3825
|
-
);
|
|
3826
|
-
}
|
|
3827
|
-
finishEnd();
|
|
3828
|
-
},
|
|
3829
|
-
...context
|
|
3830
|
-
};
|
|
3768
|
+
return activateUncaptured(
|
|
3769
|
+
"suppressed",
|
|
3770
|
+
recording,
|
|
3771
|
+
parentStore,
|
|
3772
|
+
plan,
|
|
3773
|
+
args,
|
|
3774
|
+
omitCallValues,
|
|
3775
|
+
parentCallId,
|
|
3776
|
+
startedAtNs,
|
|
3777
|
+
group,
|
|
3778
|
+
false
|
|
3779
|
+
);
|
|
3831
3780
|
}
|
|
3832
|
-
const dropWithoutCapture = (onThrow) => {
|
|
3833
|
-
uncaptured.enterActive();
|
|
3834
|
-
return {
|
|
3835
|
-
leave: (value) => {
|
|
3836
|
-
if (status !== "failed") {
|
|
3837
|
-
status = "left";
|
|
3838
|
-
pendingReturn = value;
|
|
3839
|
-
}
|
|
3840
|
-
return value;
|
|
3841
|
-
},
|
|
3842
|
-
fail: (error) => {
|
|
3843
|
-
if (status === "failed") return;
|
|
3844
|
-
status = "failed";
|
|
3845
|
-
onThrow(error);
|
|
3846
|
-
},
|
|
3847
|
-
end: () => {
|
|
3848
|
-
if (status !== "failed") {
|
|
3849
|
-
const droppedBefore = recording.journal?.dropped ?? 0;
|
|
3850
|
-
recording.journal?.dropCall();
|
|
3851
|
-
countDroppedEvents(recording, droppedBefore);
|
|
3852
|
-
}
|
|
3853
|
-
finishEnd();
|
|
3854
|
-
},
|
|
3855
|
-
...context
|
|
3856
|
-
};
|
|
3857
|
-
};
|
|
3858
3781
|
if (!journal) {
|
|
3859
3782
|
memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
},
|
|
3873
|
-
end: finishEnd,
|
|
3874
|
-
...context
|
|
3875
|
-
};
|
|
3783
|
+
return activateUncaptured(
|
|
3784
|
+
"idle",
|
|
3785
|
+
recording,
|
|
3786
|
+
parentStore,
|
|
3787
|
+
plan,
|
|
3788
|
+
args,
|
|
3789
|
+
omitCallValues,
|
|
3790
|
+
parentCallId,
|
|
3791
|
+
startedAtNs,
|
|
3792
|
+
group,
|
|
3793
|
+
false
|
|
3794
|
+
);
|
|
3876
3795
|
}
|
|
3877
3796
|
if (!journal.canStartCall()) {
|
|
3878
|
-
return
|
|
3879
|
-
|
|
3880
|
-
|
|
3797
|
+
return activateUncaptured(
|
|
3798
|
+
"dropped",
|
|
3799
|
+
recording,
|
|
3800
|
+
parentStore,
|
|
3801
|
+
plan,
|
|
3802
|
+
args,
|
|
3803
|
+
omitCallValues,
|
|
3804
|
+
parentCallId,
|
|
3805
|
+
startedAtNs,
|
|
3806
|
+
group,
|
|
3807
|
+
true
|
|
3808
|
+
);
|
|
3881
3809
|
}
|
|
3882
3810
|
if (!memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes)) {
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
},
|
|
3896
|
-
end: finishEnd,
|
|
3897
|
-
...context
|
|
3898
|
-
};
|
|
3811
|
+
return activateUncaptured(
|
|
3812
|
+
"idle",
|
|
3813
|
+
recording,
|
|
3814
|
+
parentStore,
|
|
3815
|
+
plan,
|
|
3816
|
+
args,
|
|
3817
|
+
omitCallValues,
|
|
3818
|
+
parentCallId,
|
|
3819
|
+
startedAtNs,
|
|
3820
|
+
group,
|
|
3821
|
+
false
|
|
3822
|
+
);
|
|
3899
3823
|
}
|
|
3900
3824
|
const callId = ++recording.nextCallId;
|
|
3901
3825
|
const enterTimestampNs = process.hrtime.bigint() - recording.startedAtNs;
|
|
@@ -3904,65 +3828,36 @@ var createExecutionRecorder = (options) => {
|
|
|
3904
3828
|
journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
|
|
3905
3829
|
} catch {
|
|
3906
3830
|
journal.dropCall();
|
|
3907
|
-
return
|
|
3908
|
-
|
|
3831
|
+
return activateUncaptured(
|
|
3832
|
+
"dropped",
|
|
3833
|
+
recording,
|
|
3834
|
+
parentStore,
|
|
3835
|
+
plan,
|
|
3836
|
+
args,
|
|
3837
|
+
omitCallValues,
|
|
3838
|
+
parentCallId,
|
|
3839
|
+
startedAtNs,
|
|
3840
|
+
group,
|
|
3841
|
+
false
|
|
3842
|
+
);
|
|
3909
3843
|
}
|
|
3910
3844
|
const callStore = { recording, currentCallId: callId };
|
|
3911
|
-
const captured =
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
KIND_THROW,
|
|
3928
|
-
callId,
|
|
3929
|
-
process.hrtime.bigint() - recording.startedAtNs,
|
|
3930
|
-
process.hrtime.bigint() - startedAtNs,
|
|
3931
|
-
capturedError.value
|
|
3932
|
-
);
|
|
3933
|
-
stats.functionCallsCaptured++;
|
|
3934
|
-
capturedError.commit();
|
|
3935
|
-
};
|
|
3936
|
-
return {
|
|
3937
|
-
leave: (value) => {
|
|
3938
|
-
if (status !== "failed") {
|
|
3939
|
-
status = "left";
|
|
3940
|
-
pendingReturn = value;
|
|
3941
|
-
}
|
|
3942
|
-
return value;
|
|
3943
|
-
},
|
|
3944
|
-
fail: (error) => {
|
|
3945
|
-
if (status === "failed") return;
|
|
3946
|
-
status = "failed";
|
|
3947
|
-
try {
|
|
3948
|
-
writeThrow(error);
|
|
3949
|
-
} catch {
|
|
3950
|
-
}
|
|
3951
|
-
},
|
|
3952
|
-
end: () => {
|
|
3953
|
-
try {
|
|
3954
|
-
if (status !== "failed") writeExit(status === "left" ? pendingReturn : void 0);
|
|
3955
|
-
} catch {
|
|
3956
|
-
}
|
|
3957
|
-
if (ended) return;
|
|
3958
|
-
ended = true;
|
|
3959
|
-
settleInFlight(recording);
|
|
3960
|
-
captured.restore();
|
|
3961
|
-
},
|
|
3962
|
-
run: captured.run,
|
|
3963
|
-
suspend: captured.suspend,
|
|
3964
|
-
resume: captured.resume
|
|
3965
|
-
};
|
|
3845
|
+
const captured = new CallFrame(
|
|
3846
|
+
"captured",
|
|
3847
|
+
recording,
|
|
3848
|
+
parentStore,
|
|
3849
|
+
callStore,
|
|
3850
|
+
plan,
|
|
3851
|
+
args,
|
|
3852
|
+
omitCallValues,
|
|
3853
|
+
parentCallId,
|
|
3854
|
+
startedAtNs,
|
|
3855
|
+
callId,
|
|
3856
|
+
group,
|
|
3857
|
+
false
|
|
3858
|
+
);
|
|
3859
|
+
enterStore(captured, callStore);
|
|
3860
|
+
return captured;
|
|
3966
3861
|
};
|
|
3967
3862
|
const runPreparedFunction = (plan, args, callback, omitValues) => {
|
|
3968
3863
|
const store = currentStore();
|
|
@@ -3971,51 +3866,13 @@ var createExecutionRecorder = (options) => {
|
|
|
3971
3866
|
}
|
|
3972
3867
|
return runPreparedFunctionFromStore(store, plan, args, callback, omitValues);
|
|
3973
3868
|
};
|
|
3974
|
-
const isolateHandle2 = (handle) => ({
|
|
3975
|
-
leave: (value) => {
|
|
3976
|
-
try {
|
|
3977
|
-
return handle.leave(value);
|
|
3978
|
-
} catch {
|
|
3979
|
-
return value;
|
|
3980
|
-
}
|
|
3981
|
-
},
|
|
3982
|
-
fail: (error, liveArgs) => {
|
|
3983
|
-
try {
|
|
3984
|
-
handle.fail(error, liveArgs);
|
|
3985
|
-
} catch {
|
|
3986
|
-
}
|
|
3987
|
-
},
|
|
3988
|
-
end: () => {
|
|
3989
|
-
try {
|
|
3990
|
-
handle.end();
|
|
3991
|
-
} catch {
|
|
3992
|
-
}
|
|
3993
|
-
},
|
|
3994
|
-
run: function __rasputinHandleRun__3(callback) {
|
|
3995
|
-
return runExactlyOnce((invoke) => handle.run(invoke), callback);
|
|
3996
|
-
},
|
|
3997
|
-
suspend: (value) => {
|
|
3998
|
-
try {
|
|
3999
|
-
return handle.suspend(value);
|
|
4000
|
-
} catch {
|
|
4001
|
-
return value;
|
|
4002
|
-
}
|
|
4003
|
-
},
|
|
4004
|
-
resume: (value) => {
|
|
4005
|
-
try {
|
|
4006
|
-
return handle.resume(value);
|
|
4007
|
-
} catch {
|
|
4008
|
-
return value;
|
|
4009
|
-
}
|
|
4010
|
-
}
|
|
4011
|
-
});
|
|
4012
3869
|
const enterPreparedFunction = (plan, args, omitValues) => {
|
|
4013
3870
|
try {
|
|
4014
3871
|
const store = currentStore();
|
|
4015
3872
|
if (store && !store.recording.finished && !store.recording.sawAutomatic) {
|
|
4016
3873
|
store.recording.sawAutomatic = true;
|
|
4017
3874
|
}
|
|
4018
|
-
return
|
|
3875
|
+
return enterPreparedFunctionFromStore(store, plan, args, omitValues);
|
|
4019
3876
|
} catch {
|
|
4020
3877
|
return noopHandle2;
|
|
4021
3878
|
}
|
|
@@ -4042,14 +3899,14 @@ var createExecutionRecorder = (options) => {
|
|
|
4042
3899
|
function trace(input, fn) {
|
|
4043
3900
|
const definition = typeof input === "string" ? manualFunctionDefinition(input) : { ...input, functionId: runtimeFunctionId2(input) };
|
|
4044
3901
|
const plan = preparePlan(definition);
|
|
4045
|
-
return function
|
|
3902
|
+
return function __rasputinHandleRun__4(...args) {
|
|
4046
3903
|
if (new.target) {
|
|
4047
3904
|
throw new TypeError("execution.trace() wraps function calls, not constructors");
|
|
4048
3905
|
}
|
|
4049
3906
|
const receiver = this;
|
|
4050
3907
|
const store = currentStore();
|
|
4051
3908
|
if (store && !store.recording.finished) store.recording.sawManual = true;
|
|
4052
|
-
return runPreparedFunctionFromStore(store, plan, args, function
|
|
3909
|
+
return runPreparedFunctionFromStore(store, plan, args, function __rasputinHandleRun__5() {
|
|
4053
3910
|
return fn.apply(receiver, args);
|
|
4054
3911
|
});
|
|
4055
3912
|
};
|
|
@@ -4085,9 +3942,7 @@ var bindExecution = (execution, module) => {
|
|
|
4085
3942
|
module.cell.enter = (planIndex, args, omitValues) => {
|
|
4086
3943
|
try {
|
|
4087
3944
|
const plan = prepared[planIndex];
|
|
4088
|
-
return
|
|
4089
|
-
plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughHandle()
|
|
4090
|
-
);
|
|
3945
|
+
return plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughHandle();
|
|
4091
3946
|
} catch {
|
|
4092
3947
|
return passthroughHandle();
|
|
4093
3948
|
}
|