@rasputin-ai/node 0.9.0 → 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/auto-instrumentation/format-configuration-report.d.ts.map +1 -1
- 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 +496 -627
- package/dist/instrument/bun.js +1 -1
- package/dist/instrument/node.js +1 -1
- package/dist/internal.js +493 -626
- 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
|
@@ -26,6 +26,9 @@ var issueHeadline = (issue) => {
|
|
|
26
26
|
if (issue.reason === "invalid_mapping") {
|
|
27
27
|
return `The configured package root for ${target} does not match this Git release.`;
|
|
28
28
|
}
|
|
29
|
+
if (issue.reason === "commit_not_found") {
|
|
30
|
+
return `GitHub does not have this release commit while locating ${target}.`;
|
|
31
|
+
}
|
|
29
32
|
return `GitHub could not be reached while locating ${target}.`;
|
|
30
33
|
};
|
|
31
34
|
var formatIssue = (issue) => {
|
|
@@ -44,8 +47,11 @@ var formatIssue = (issue) => {
|
|
|
44
47
|
var formatConfigurationReport = (input) => {
|
|
45
48
|
const packages = input.verification.packages ?? [];
|
|
46
49
|
const unresolved = input.verification.unresolved;
|
|
47
|
-
const mappingIssues = unresolved.filter(
|
|
50
|
+
const mappingIssues = unresolved.filter(
|
|
51
|
+
(issue) => issue.reason !== "github_unavailable" && issue.reason !== "commit_not_found"
|
|
52
|
+
);
|
|
48
53
|
const githubUnavailable = input.verification.status === "unavailable" || unresolved.some((issue) => issue.reason === "github_unavailable");
|
|
54
|
+
const commitNotFound = input.verification.status === "commit_not_found";
|
|
49
55
|
const verified = input.uploaded && input.verification.status === "verified";
|
|
50
56
|
const lines = [
|
|
51
57
|
...BANNER,
|
|
@@ -84,13 +90,19 @@ var formatConfigurationReport = (input) => {
|
|
|
84
90
|
lines.push("! upload failed");
|
|
85
91
|
} else {
|
|
86
92
|
lines.push("\u2713 uploaded");
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
)
|
|
93
|
+
if (verified) {
|
|
94
|
+
lines.push("\u2713 verified against GitHub");
|
|
95
|
+
} else if (commitNotFound) {
|
|
96
|
+
lines.push("! this Git commit was not found in the connected repository");
|
|
97
|
+
} else {
|
|
98
|
+
lines.push("! some source files could not be mapped to this Git release");
|
|
99
|
+
}
|
|
90
100
|
}
|
|
91
101
|
lines.push("", "GitHub");
|
|
92
102
|
if (!input.uploaded) {
|
|
93
103
|
lines.push("! not verified");
|
|
104
|
+
} else if (commitNotFound) {
|
|
105
|
+
lines.push("! push this commit to GitHub so Rasputin can map source");
|
|
94
106
|
} else if (githubUnavailable) {
|
|
95
107
|
lines.push("! repository is not connected, or this release could not be read");
|
|
96
108
|
} else {
|
|
@@ -118,7 +130,7 @@ import {
|
|
|
118
130
|
// ../recorder/src/run-exactly-once.ts
|
|
119
131
|
var runExactlyOnce = function __rasputinHandleRun__(invoke, callback) {
|
|
120
132
|
let outcome;
|
|
121
|
-
const wrapped = function
|
|
133
|
+
const wrapped = function __rasputinHandleRun__4() {
|
|
122
134
|
try {
|
|
123
135
|
const value = callback();
|
|
124
136
|
outcome = { kind: "value", value };
|
|
@@ -138,56 +150,19 @@ var runExactlyOnce = function __rasputinHandleRun__(invoke, callback) {
|
|
|
138
150
|
};
|
|
139
151
|
|
|
140
152
|
// ../recorder/src/call-handle.ts
|
|
141
|
-
var
|
|
153
|
+
var sharedPassthroughHandle = {
|
|
142
154
|
leave: (value) => value,
|
|
143
155
|
fail: () => {
|
|
144
156
|
},
|
|
145
157
|
end: () => {
|
|
146
158
|
},
|
|
147
|
-
run: function
|
|
159
|
+
run: function __rasputinHandleRun__2(callback) {
|
|
148
160
|
return runExactlyOnce((invoke) => invoke(), callback);
|
|
149
161
|
},
|
|
150
162
|
suspend: (value) => value,
|
|
151
163
|
resume: (value) => value
|
|
152
|
-
}
|
|
153
|
-
var
|
|
154
|
-
leave: (value) => {
|
|
155
|
-
try {
|
|
156
|
-
return handle.leave(value);
|
|
157
|
-
} catch {
|
|
158
|
-
return value;
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
fail: (error, liveArgs) => {
|
|
162
|
-
try {
|
|
163
|
-
handle.fail(error, liveArgs);
|
|
164
|
-
} catch {
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
end: () => {
|
|
168
|
-
try {
|
|
169
|
-
handle.end();
|
|
170
|
-
} catch {
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
run: function __rasputinHandleRun__3(callback) {
|
|
174
|
-
return runExactlyOnce((invoke) => handle.run(invoke), callback);
|
|
175
|
-
},
|
|
176
|
-
suspend: (value) => {
|
|
177
|
-
try {
|
|
178
|
-
return handle.suspend(value);
|
|
179
|
-
} catch {
|
|
180
|
-
return value;
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
resume: (value) => {
|
|
184
|
-
try {
|
|
185
|
-
return handle.resume(value);
|
|
186
|
-
} catch {
|
|
187
|
-
return value;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
});
|
|
164
|
+
};
|
|
165
|
+
var passthroughHandle = () => sharedPassthroughHandle;
|
|
191
166
|
|
|
192
167
|
// ../recorder/src/encoded-function-plan.ts
|
|
193
168
|
var encodedPlanOmitsCallValues = (plan) => plan[6] === 1;
|
|
@@ -566,7 +541,7 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
566
541
|
failedAttempts = 0;
|
|
567
542
|
clearRetry();
|
|
568
543
|
if (verification.status === "verified") {
|
|
569
|
-
if (!loggedSuccess && options.logSuccess
|
|
544
|
+
if (!loggedSuccess && options.logSuccess === true) {
|
|
570
545
|
loggedSuccess = true;
|
|
571
546
|
console.info(report(manifest, true, verification));
|
|
572
547
|
}
|
|
@@ -660,7 +635,6 @@ var scheduleInstrumentationManifestUpload = (options) => {
|
|
|
660
635
|
// src/execution-recorder/execution-recorder.ts
|
|
661
636
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
662
637
|
import {
|
|
663
|
-
createEnvSecretMatcher,
|
|
664
638
|
rasputinOmitted,
|
|
665
639
|
rasputinTagKind,
|
|
666
640
|
runtimeFunctionId as runtimeFunctionId2
|
|
@@ -1107,7 +1081,7 @@ var RecorderMemoryBudget = class {
|
|
|
1107
1081
|
}
|
|
1108
1082
|
return allocation;
|
|
1109
1083
|
}
|
|
1110
|
-
captureValue(allocation,
|
|
1084
|
+
captureValue(allocation, value, freeze) {
|
|
1111
1085
|
if (allocation.released) {
|
|
1112
1086
|
this.dropValues(allocation, 1);
|
|
1113
1087
|
return MEMORY_BUDGET_VALUE_MARKER;
|
|
@@ -1122,13 +1096,13 @@ var RecorderMemoryBudget = class {
|
|
|
1122
1096
|
this.dropValues(allocation, 1);
|
|
1123
1097
|
return MEMORY_BUDGET_VALUE_MARKER;
|
|
1124
1098
|
}
|
|
1125
|
-
const
|
|
1126
|
-
if (!this.reserve(allocation,
|
|
1099
|
+
const frozen = freeze(value);
|
|
1100
|
+
if (!this.reserve(allocation, frozen.estimatedBytes * VALUE_HEAP_ESTIMATE_MULTIPLIER)) {
|
|
1127
1101
|
this.markPressure(allocation, "structure-only");
|
|
1128
1102
|
this.dropValues(allocation, 1);
|
|
1129
1103
|
return MEMORY_BUDGET_VALUE_MARKER;
|
|
1130
1104
|
}
|
|
1131
|
-
return
|
|
1105
|
+
return frozen.value;
|
|
1132
1106
|
}
|
|
1133
1107
|
reserveCall(allocation, estimatedBytes) {
|
|
1134
1108
|
if (allocation.mode === "metadata-only") {
|
|
@@ -1212,7 +1186,16 @@ import {
|
|
|
1212
1186
|
} from "@rasputin-ai/core";
|
|
1213
1187
|
var MAX_RUNTIME_STATE_BYTES = 256 * 1024;
|
|
1214
1188
|
var VALUE_OMITTED_REASON = "runtime_state_size_budget";
|
|
1215
|
-
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
|
+
};
|
|
1216
1199
|
var sizeMetadata = (originalBytes) => ({
|
|
1217
1200
|
reason: "runtime_state_size_budget",
|
|
1218
1201
|
originalBytes,
|
|
@@ -1378,51 +1361,12 @@ var enforceRuntimeStateSizeBudget = (input) => {
|
|
|
1378
1361
|
|
|
1379
1362
|
// src/execution-recorder/encode-frozen.ts
|
|
1380
1363
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
1381
|
-
import { RASPUTIN_REDACTED
|
|
1364
|
+
import { RASPUTIN_REDACTED } from "@rasputin-ai/core";
|
|
1382
1365
|
|
|
1383
1366
|
// src/execution-recorder/value-freeze.ts
|
|
1384
1367
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
1385
1368
|
import { types } from "node:util";
|
|
1386
|
-
import {
|
|
1387
|
-
MAX_ENV_SECRET_NEEDLE_LENGTH,
|
|
1388
|
-
RASPUTIN_REDACTED,
|
|
1389
|
-
RASPUTIN_WIRE_TAG
|
|
1390
|
-
} from "@rasputin-ai/core";
|
|
1391
|
-
|
|
1392
|
-
// src/execution-recorder/redact-keys.ts
|
|
1393
|
-
import { defaultSensitivePropertyNames, propertyNameIsSensitive } from "@rasputin-ai/core";
|
|
1394
|
-
var compactKey = (key) => {
|
|
1395
|
-
let compacted = "";
|
|
1396
|
-
for (let index = 0; index < key.length; index++) {
|
|
1397
|
-
const code = key.charCodeAt(index);
|
|
1398
|
-
if (code === 45 || code === 46 || code === 95) continue;
|
|
1399
|
-
compacted += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : key[index];
|
|
1400
|
-
}
|
|
1401
|
-
return compacted;
|
|
1402
|
-
};
|
|
1403
|
-
var stripTrailingDigits = (value) => {
|
|
1404
|
-
let end = value.length;
|
|
1405
|
-
while (end > 0) {
|
|
1406
|
-
const code = value.charCodeAt(end - 1);
|
|
1407
|
-
if (code < 48 || code > 57) break;
|
|
1408
|
-
end--;
|
|
1409
|
-
}
|
|
1410
|
-
return end === 0 ? value : value.slice(0, end);
|
|
1411
|
-
};
|
|
1412
|
-
var normalizeKey = (key) => stripTrailingDigits(compactKey(key));
|
|
1413
|
-
var compileRedactKeys = (extra) => {
|
|
1414
|
-
if (!extra?.length) return defaultSensitivePropertyNames();
|
|
1415
|
-
return /* @__PURE__ */ new Set([...defaultSensitivePropertyNames(), ...extra.map(normalizeKey)]);
|
|
1416
|
-
};
|
|
1417
|
-
var keyIsRedacted = (key, redactKeys) => {
|
|
1418
|
-
if (propertyNameIsSensitive(key)) return true;
|
|
1419
|
-
if (redactKeys.has(key)) return true;
|
|
1420
|
-
const compacted = compactKey(key);
|
|
1421
|
-
if (redactKeys.has(compacted)) return true;
|
|
1422
|
-
return redactKeys.has(stripTrailingDigits(compacted));
|
|
1423
|
-
};
|
|
1424
|
-
|
|
1425
|
-
// src/execution-recorder/value-freeze.ts
|
|
1369
|
+
import { RASPUTIN_WIRE_TAG } from "@rasputin-ai/core";
|
|
1426
1370
|
var defaults = {
|
|
1427
1371
|
maxDepth: 3,
|
|
1428
1372
|
maxObjectKeys: 30,
|
|
@@ -1450,16 +1394,20 @@ var atom = (kind, extra = {}) => ({
|
|
|
1450
1394
|
[FROZEN]: kind,
|
|
1451
1395
|
...extra
|
|
1452
1396
|
});
|
|
1453
|
-
var
|
|
1397
|
+
var NO_DATA = Symbol("rasputin.no-data");
|
|
1398
|
+
var ownValue = (value, key) => {
|
|
1454
1399
|
try {
|
|
1455
1400
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
1456
|
-
if (
|
|
1457
|
-
|
|
1458
|
-
return void 0;
|
|
1401
|
+
if (descriptor && "value" in descriptor) return descriptor.value;
|
|
1402
|
+
return NO_DATA;
|
|
1459
1403
|
} catch {
|
|
1460
|
-
return
|
|
1404
|
+
return NO_DATA;
|
|
1461
1405
|
}
|
|
1462
1406
|
};
|
|
1407
|
+
var copyBoundedString = (value) => {
|
|
1408
|
+
if (value.length === 0) return value;
|
|
1409
|
+
return Buffer2.from(value, "utf16le").toString("utf16le");
|
|
1410
|
+
};
|
|
1463
1411
|
var nativeErrorStackGet = (() => {
|
|
1464
1412
|
try {
|
|
1465
1413
|
return Object.getOwnPropertyDescriptor(Error.prototype, "stack")?.get;
|
|
@@ -1515,8 +1463,8 @@ var isDomException = (value) => {
|
|
|
1515
1463
|
}
|
|
1516
1464
|
};
|
|
1517
1465
|
var functionNameOf = (value) => {
|
|
1518
|
-
const
|
|
1519
|
-
if (
|
|
1466
|
+
const name = ownValue(value, "name");
|
|
1467
|
+
if (typeof name === "string" && name.length > 0) return name;
|
|
1520
1468
|
return "anonymous";
|
|
1521
1469
|
};
|
|
1522
1470
|
var errorNameOf = (value) => {
|
|
@@ -1529,8 +1477,8 @@ var errorNameOf = (value) => {
|
|
|
1529
1477
|
}
|
|
1530
1478
|
let current = value;
|
|
1531
1479
|
while (current) {
|
|
1532
|
-
const
|
|
1533
|
-
if (
|
|
1480
|
+
const name = ownValue(current, "name");
|
|
1481
|
+
if (typeof name === "string" && name.length > 0) return name;
|
|
1534
1482
|
try {
|
|
1535
1483
|
current = Object.getPrototypeOf(current);
|
|
1536
1484
|
} catch {
|
|
@@ -1546,8 +1494,8 @@ var errorMessageOf = (value) => {
|
|
|
1546
1494
|
} catch {
|
|
1547
1495
|
}
|
|
1548
1496
|
}
|
|
1549
|
-
const
|
|
1550
|
-
if (
|
|
1497
|
+
const message = ownValue(value, "message");
|
|
1498
|
+
if (message !== NO_DATA) return message;
|
|
1551
1499
|
if (!nativeErrorMessageGet) return void 0;
|
|
1552
1500
|
try {
|
|
1553
1501
|
return nativeErrorMessageGet.call(value);
|
|
@@ -1556,8 +1504,8 @@ var errorMessageOf = (value) => {
|
|
|
1556
1504
|
}
|
|
1557
1505
|
};
|
|
1558
1506
|
var errorStackOf = (value) => withoutPrepareStackTrace(() => {
|
|
1559
|
-
const
|
|
1560
|
-
if (
|
|
1507
|
+
const ownStack = ownValue(value, "stack");
|
|
1508
|
+
if (typeof ownStack === "string" && ownStack.length > 0) return ownStack;
|
|
1561
1509
|
try {
|
|
1562
1510
|
const getter = Object.getOwnPropertyDescriptor(value, "stack")?.get;
|
|
1563
1511
|
if (getter && nativeInstanceStackGet && getter === nativeInstanceStackGet) {
|
|
@@ -1617,24 +1565,23 @@ var sampleBytes = (bytes, max) => {
|
|
|
1617
1565
|
for (let index = 0; index < length; index++) sample[index] = bytes[index] ?? 0;
|
|
1618
1566
|
return sample;
|
|
1619
1567
|
};
|
|
1620
|
-
var
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
"
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
var assignFrozenField = (fields, key, value) => {
|
|
1630
|
-
if (RESERVED_USER_KEYS.has(key) || key.startsWith("__rasputin_")) {
|
|
1631
|
-
const escaped = fields.__rasputin_fields ?? [];
|
|
1632
|
-
escaped.push({ name: key, value });
|
|
1633
|
-
fields.__rasputin_fields = escaped;
|
|
1634
|
-
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);
|
|
1635
1577
|
}
|
|
1636
|
-
|
|
1578
|
+
return meta;
|
|
1637
1579
|
};
|
|
1580
|
+
var frozenRecord = (keys, values) => ({
|
|
1581
|
+
[FROZEN]: "record",
|
|
1582
|
+
keys,
|
|
1583
|
+
values
|
|
1584
|
+
});
|
|
1638
1585
|
var ownEnumerableKeys = (value, maxKeys) => {
|
|
1639
1586
|
const keys = [];
|
|
1640
1587
|
let proto = null;
|
|
@@ -1664,97 +1611,8 @@ var bufferByteLength = (value) => {
|
|
|
1664
1611
|
}
|
|
1665
1612
|
};
|
|
1666
1613
|
var stringEstimate = (value) => NODE + 2 + Buffer2.byteLength(value, "utf8");
|
|
1667
|
-
var URL_LIKE_PROPERTY_NAMES = /* @__PURE__ */ new Set([
|
|
1668
|
-
"url",
|
|
1669
|
-
"href",
|
|
1670
|
-
"originalurl",
|
|
1671
|
-
"path",
|
|
1672
|
-
"pathname",
|
|
1673
|
-
"search",
|
|
1674
|
-
"query",
|
|
1675
|
-
"requesturl",
|
|
1676
|
-
"requesturi",
|
|
1677
|
-
"location",
|
|
1678
|
-
"referer",
|
|
1679
|
-
"referrer",
|
|
1680
|
-
"uri",
|
|
1681
|
-
"connectionuri",
|
|
1682
|
-
"connectionurl",
|
|
1683
|
-
"databaseuri",
|
|
1684
|
-
"databaseurl",
|
|
1685
|
-
"mongouri",
|
|
1686
|
-
"mongourl",
|
|
1687
|
-
"redisuri",
|
|
1688
|
-
"redisurl",
|
|
1689
|
-
"postgresuri",
|
|
1690
|
-
"postgresurl"
|
|
1691
|
-
]);
|
|
1692
|
-
var compactPropertyName = (key) => {
|
|
1693
|
-
let compacted = "";
|
|
1694
|
-
for (let index = 0; index < key.length; index++) {
|
|
1695
|
-
const code = key.charCodeAt(index);
|
|
1696
|
-
if (code === 45 || code === 46 || code === 95) continue;
|
|
1697
|
-
compacted += code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : key[index];
|
|
1698
|
-
}
|
|
1699
|
-
return compacted;
|
|
1700
|
-
};
|
|
1701
|
-
var propertyNameLooksLikeUrl = (key) => URL_LIKE_PROPERTY_NAMES.has(compactPropertyName(key));
|
|
1702
|
-
var looksLikeBareQueryString = (text) => {
|
|
1703
|
-
if (!text.includes("=") || /\s/.test(text)) return false;
|
|
1704
|
-
if (/^[a-z][a-z0-9+.-]*:/i.test(text) || text.startsWith("/")) return false;
|
|
1705
|
-
return /^[^\s=]+=[^\s]*(&[^\s=]+=[^\s]*)*$/.test(text);
|
|
1706
|
-
};
|
|
1707
|
-
var redactSensitiveQuery = (text, redactKeys) => {
|
|
1708
|
-
const queryAt = text.indexOf("?");
|
|
1709
|
-
let prefix = "";
|
|
1710
|
-
let query = "";
|
|
1711
|
-
let suffix = "";
|
|
1712
|
-
if (queryAt >= 0) {
|
|
1713
|
-
if (queryAt === text.length - 1) return text;
|
|
1714
|
-
const hashAt = text.indexOf("#", queryAt + 1);
|
|
1715
|
-
prefix = text.slice(0, queryAt + 1);
|
|
1716
|
-
query = hashAt < 0 ? text.slice(queryAt + 1) : text.slice(queryAt + 1, hashAt);
|
|
1717
|
-
suffix = hashAt < 0 ? "" : text.slice(hashAt);
|
|
1718
|
-
} else if (looksLikeBareQueryString(text)) {
|
|
1719
|
-
query = text;
|
|
1720
|
-
} else {
|
|
1721
|
-
return text;
|
|
1722
|
-
}
|
|
1723
|
-
if (!query.includes("=")) return text;
|
|
1724
|
-
let changed = false;
|
|
1725
|
-
const next = query.split("&").map((part) => {
|
|
1726
|
-
const equals = part.indexOf("=");
|
|
1727
|
-
const rawKey = equals < 0 ? part : part.slice(0, equals);
|
|
1728
|
-
if (!rawKey) return part;
|
|
1729
|
-
let decoded = rawKey;
|
|
1730
|
-
try {
|
|
1731
|
-
decoded = decodeURIComponent(rawKey.replace(/\+/g, " "));
|
|
1732
|
-
} catch {
|
|
1733
|
-
decoded = rawKey;
|
|
1734
|
-
}
|
|
1735
|
-
if (!keyIsRedacted(decoded, redactKeys) && !keyIsRedacted(rawKey, redactKeys)) return part;
|
|
1736
|
-
changed = true;
|
|
1737
|
-
return `${rawKey}=${RASPUTIN_REDACTED}`;
|
|
1738
|
-
});
|
|
1739
|
-
if (!changed) return text;
|
|
1740
|
-
return `${prefix}${next.join("&")}${suffix}`;
|
|
1741
|
-
};
|
|
1742
|
-
var redactUrlUserinfo = (text) => {
|
|
1743
|
-
const schemeEnd = text.indexOf("://");
|
|
1744
|
-
if (schemeEnd <= 0) return text;
|
|
1745
|
-
const rest = text.slice(schemeEnd + 3);
|
|
1746
|
-
let authorityEnd = rest.length;
|
|
1747
|
-
for (const marker of ["/", "?", "#"]) {
|
|
1748
|
-
const at = rest.indexOf(marker);
|
|
1749
|
-
if (at >= 0 && at < authorityEnd) authorityEnd = at;
|
|
1750
|
-
}
|
|
1751
|
-
const authority = rest.slice(0, authorityEnd);
|
|
1752
|
-
const userinfoEnd = authority.lastIndexOf("@");
|
|
1753
|
-
if (userinfoEnd < 0) return text;
|
|
1754
|
-
return `${text.slice(0, schemeEnd + 3)}${RASPUTIN_REDACTED}@${authority.slice(userinfoEnd + 1)}${rest.slice(authorityEnd)}`;
|
|
1755
|
-
};
|
|
1756
|
-
var redactUrlLikeString = (text, redactKeys) => redactSensitiveQuery(redactUrlUserinfo(text), redactKeys);
|
|
1757
1614
|
var isFrozenAtom = (value) => typeof value === "object" && value !== null && FROZEN in value;
|
|
1615
|
+
var isFrozenRecord = (value) => isFrozenAtom(value) && value[FROZEN] === "record";
|
|
1758
1616
|
var isRetainedOverflowChild = (value) => {
|
|
1759
1617
|
if (isFrozenAtom(value)) {
|
|
1760
1618
|
if (value[FROZEN] === "truncated") return true;
|
|
@@ -1772,16 +1630,13 @@ var keepOverflowChild = (child, overflowedOnChild) => {
|
|
|
1772
1630
|
var BYTE_LIMIT = "max_serialized_value_bytes";
|
|
1773
1631
|
var createValueFreezer = (options = {}) => {
|
|
1774
1632
|
const limits = compileFreezeLimits(options);
|
|
1775
|
-
const redactKeys = compileRedactKeys(options.redactKeys);
|
|
1776
|
-
const redactSecretValues = options.redactSecretValues;
|
|
1777
1633
|
const sharedPath = /* @__PURE__ */ new Set();
|
|
1778
1634
|
let freezing = false;
|
|
1779
1635
|
const add = (metrics, count) => {
|
|
1780
1636
|
metrics.estimatedBytes += count;
|
|
1781
1637
|
if (metrics.estimatedBytes > limits.maxSerializedValueBytes) metrics.oversize = true;
|
|
1782
1638
|
};
|
|
1783
|
-
const
|
|
1784
|
-
if (metrics.oversize) return void 0;
|
|
1639
|
+
const freezeLeaf = (value, metrics) => {
|
|
1785
1640
|
metrics.visitedNodes++;
|
|
1786
1641
|
if (value === null) {
|
|
1787
1642
|
add(metrics, 4);
|
|
@@ -1801,16 +1656,11 @@ var createValueFreezer = (options = {}) => {
|
|
|
1801
1656
|
return value;
|
|
1802
1657
|
}
|
|
1803
1658
|
if (typeof value === "string") {
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
text = redactSecretValues(value.length > cap ? value.slice(0, cap) : value);
|
|
1808
|
-
}
|
|
1809
|
-
if (text.length <= limits.maxStringLength) {
|
|
1810
|
-
add(metrics, stringEstimate(text));
|
|
1811
|
-
return text;
|
|
1659
|
+
if (value.length <= limits.maxStringLength) {
|
|
1660
|
+
add(metrics, stringEstimate(value));
|
|
1661
|
+
return value;
|
|
1812
1662
|
}
|
|
1813
|
-
const sliced =
|
|
1663
|
+
const sliced = copyBoundedString(value.slice(0, limits.maxStringLength));
|
|
1814
1664
|
add(metrics, NODE + stringEstimate(sliced) + 48);
|
|
1815
1665
|
return atom("truncated", {
|
|
1816
1666
|
reason: "max_string_length",
|
|
@@ -1841,10 +1691,13 @@ var createValueFreezer = (options = {}) => {
|
|
|
1841
1691
|
add(metrics, NODE + stringEstimate(name));
|
|
1842
1692
|
return atom("function", { value: name });
|
|
1843
1693
|
}
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
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++;
|
|
1848
1701
|
if (path.has(value)) {
|
|
1849
1702
|
add(metrics, NODE + 16);
|
|
1850
1703
|
return atom("circular");
|
|
@@ -1873,9 +1726,9 @@ var createValueFreezer = (options = {}) => {
|
|
|
1873
1726
|
const stack = errorStackOf(value);
|
|
1874
1727
|
const extras = {};
|
|
1875
1728
|
for (const key of ["code", "cause", "statusCode"]) {
|
|
1876
|
-
const
|
|
1877
|
-
if (
|
|
1878
|
-
extras[key] = freezeInner(
|
|
1729
|
+
const extra = ownValue(value, key);
|
|
1730
|
+
if (extra === NO_DATA) continue;
|
|
1731
|
+
extras[key] = freezeInner(extra, depth + 1, path, metrics);
|
|
1879
1732
|
}
|
|
1880
1733
|
return atom("Error", {
|
|
1881
1734
|
name,
|
|
@@ -1909,20 +1762,14 @@ var createValueFreezer = (options = {}) => {
|
|
|
1909
1762
|
if (counted2 >= limits.maxArrayElements || metrics.oversize) break;
|
|
1910
1763
|
const key = freezeInner(mapKey, depth + 1, path, metrics);
|
|
1911
1764
|
if (!keepOverflowChild(key, metrics.oversize)) break;
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
path,
|
|
1921
|
-
metrics
|
|
1922
|
-
);
|
|
1923
|
-
if (!keepOverflowChild(mapValue, metrics.oversize)) break;
|
|
1924
|
-
entries.push([key, mapValue]);
|
|
1925
|
-
}
|
|
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]);
|
|
1926
1773
|
counted2++;
|
|
1927
1774
|
}
|
|
1928
1775
|
const hitBytes2 = metrics.oversize && counted2 < Math.min(size, limits.maxArrayElements);
|
|
@@ -1964,7 +1811,6 @@ var createValueFreezer = (options = {}) => {
|
|
|
1964
1811
|
add(metrics, 2);
|
|
1965
1812
|
const items = [];
|
|
1966
1813
|
const maxItems = value.length > limits.maxArrayElements ? limits.maxArrayElements - 1 : value.length;
|
|
1967
|
-
let redactNext = false;
|
|
1968
1814
|
for (let index = 0; index < maxItems; index++) {
|
|
1969
1815
|
if (metrics.oversize) break;
|
|
1970
1816
|
let descriptor;
|
|
@@ -1977,27 +1823,17 @@ var createValueFreezer = (options = {}) => {
|
|
|
1977
1823
|
add(metrics, NODE + 16);
|
|
1978
1824
|
if (metrics.oversize) break;
|
|
1979
1825
|
items.push(atom("hole"));
|
|
1980
|
-
redactNext = false;
|
|
1981
1826
|
continue;
|
|
1982
1827
|
}
|
|
1983
1828
|
if (!("value" in descriptor)) {
|
|
1984
1829
|
add(metrics, NODE + 16);
|
|
1985
1830
|
if (metrics.oversize) break;
|
|
1986
1831
|
items.push(atom("accessor"));
|
|
1987
|
-
redactNext = false;
|
|
1988
1832
|
continue;
|
|
1989
1833
|
}
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
items.push(RASPUTIN_REDACTED);
|
|
1994
|
-
redactNext = false;
|
|
1995
|
-
} else {
|
|
1996
|
-
const frozen = freezeInner(descriptor.value, depth + 1, path, metrics);
|
|
1997
|
-
if (!keepOverflowChild(frozen, metrics.oversize)) break;
|
|
1998
|
-
items.push(frozen);
|
|
1999
|
-
redactNext = typeof descriptor.value === "string" && keyIsRedacted(descriptor.value, redactKeys);
|
|
2000
|
-
}
|
|
1834
|
+
const frozen = freezeInner(descriptor.value, depth + 1, path, metrics);
|
|
1835
|
+
if (!keepOverflowChild(frozen, metrics.oversize)) break;
|
|
1836
|
+
items.push(frozen);
|
|
2001
1837
|
}
|
|
2002
1838
|
if (metrics.oversize && items.length < maxItems) {
|
|
2003
1839
|
add(metrics, NODE + 32);
|
|
@@ -2088,7 +1924,8 @@ var createValueFreezer = (options = {}) => {
|
|
|
2088
1924
|
}
|
|
2089
1925
|
}
|
|
2090
1926
|
add(metrics, 2);
|
|
2091
|
-
const
|
|
1927
|
+
const recordKeys = [];
|
|
1928
|
+
const recordValues = [];
|
|
2092
1929
|
let typeName;
|
|
2093
1930
|
let prototype = null;
|
|
2094
1931
|
try {
|
|
@@ -2098,12 +1935,12 @@ var createValueFreezer = (options = {}) => {
|
|
|
2098
1935
|
}
|
|
2099
1936
|
if (prototype && types.isProxy(prototype)) {
|
|
2100
1937
|
add(metrics, NODE + 16);
|
|
2101
|
-
return atom("instance", { type: "Proxy", value:
|
|
1938
|
+
return atom("instance", { type: "Proxy", value: frozenRecord(recordKeys, recordValues) });
|
|
2102
1939
|
}
|
|
2103
1940
|
if (prototype && prototype !== Object.prototype) {
|
|
2104
1941
|
typeName = "instance";
|
|
2105
1942
|
if (!types.isProxy(prototype)) {
|
|
2106
|
-
const ctor =
|
|
1943
|
+
const ctor = ownValue(prototype, "constructor");
|
|
2107
1944
|
if (typeof ctor === "function") {
|
|
2108
1945
|
const name = functionNameOf(ctor);
|
|
2109
1946
|
if (name && name !== "anonymous") typeName = name;
|
|
@@ -2111,8 +1948,6 @@ var createValueFreezer = (options = {}) => {
|
|
|
2111
1948
|
}
|
|
2112
1949
|
add(metrics, NODE + stringEstimate(typeName));
|
|
2113
1950
|
}
|
|
2114
|
-
const pairLabel = ownData(value, "name") ?? ownData(value, "key");
|
|
2115
|
-
const pairIsSensitive = pairLabel !== void 0 && typeof pairLabel.value === "string" && keyIsRedacted(pairLabel.value, redactKeys);
|
|
2116
1951
|
const { keys, truncated } = ownEnumerableKeys(value, limits.maxObjectKeys);
|
|
2117
1952
|
const maxKeys = truncated ? Math.max(0, limits.maxObjectKeys - 1) : keys.length;
|
|
2118
1953
|
let kept = 0;
|
|
@@ -2120,40 +1955,35 @@ var createValueFreezer = (options = {}) => {
|
|
|
2120
1955
|
if (metrics.oversize) break;
|
|
2121
1956
|
const key = keys[index];
|
|
2122
1957
|
if (key === void 0) continue;
|
|
2123
|
-
add(metrics,
|
|
1958
|
+
add(metrics, NODE + 2 + keyMeta(key).utf8Bytes);
|
|
2124
1959
|
if (metrics.oversize) break;
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
assignFrozenField(fields, key, RASPUTIN_REDACTED);
|
|
2129
|
-
kept++;
|
|
2130
|
-
continue;
|
|
2131
|
-
}
|
|
2132
|
-
const slot = ownData(value, key);
|
|
2133
|
-
if (slot) {
|
|
2134
|
-
const field = typeof slot.value === "string" && propertyNameLooksLikeUrl(key) ? redactUrlLikeString(slot.value, redactKeys) : slot.value;
|
|
2135
|
-
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);
|
|
2136
1963
|
if (!keepOverflowChild(frozen, metrics.oversize)) break;
|
|
2137
|
-
|
|
1964
|
+
recordKeys.push(key);
|
|
1965
|
+
recordValues.push(frozen);
|
|
2138
1966
|
kept++;
|
|
2139
1967
|
} else {
|
|
2140
1968
|
add(metrics, NODE + 16);
|
|
2141
1969
|
if (metrics.oversize) break;
|
|
2142
|
-
|
|
1970
|
+
recordKeys.push(key);
|
|
1971
|
+
recordValues.push(atom("accessor"));
|
|
2143
1972
|
kept++;
|
|
2144
1973
|
}
|
|
2145
1974
|
}
|
|
1975
|
+
const record = frozenRecord(recordKeys, recordValues);
|
|
2146
1976
|
const hitBytes = metrics.oversize && kept < maxKeys;
|
|
2147
1977
|
if (hitBytes || truncated) {
|
|
2148
1978
|
return atom("instance", {
|
|
2149
1979
|
type: typeName,
|
|
2150
|
-
value:
|
|
1980
|
+
value: record,
|
|
2151
1981
|
truncated: true,
|
|
2152
1982
|
reason: hitBytes ? BYTE_LIMIT : "max_object_keys"
|
|
2153
1983
|
});
|
|
2154
1984
|
}
|
|
2155
|
-
if (typeName) return atom("instance", { type: typeName, value:
|
|
2156
|
-
return
|
|
1985
|
+
if (typeName) return atom("instance", { type: typeName, value: record });
|
|
1986
|
+
return record;
|
|
2157
1987
|
} catch (error) {
|
|
2158
1988
|
add(metrics, NODE + 32);
|
|
2159
1989
|
return atom("unserializable", {
|
|
@@ -2164,30 +1994,43 @@ var createValueFreezer = (options = {}) => {
|
|
|
2164
1994
|
}
|
|
2165
1995
|
};
|
|
2166
1996
|
const freeze = (value) => {
|
|
2167
|
-
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
|
+
}
|
|
2168
2016
|
const reentrant = freezing;
|
|
2169
2017
|
const path = reentrant ? /* @__PURE__ */ new Set() : sharedPath;
|
|
2170
2018
|
if (!reentrant) {
|
|
2171
2019
|
freezing = true;
|
|
2172
|
-
sharedPath.clear();
|
|
2020
|
+
if (sharedPath.size !== 0) sharedPath.clear();
|
|
2173
2021
|
}
|
|
2174
2022
|
try {
|
|
2175
|
-
|
|
2176
|
-
return
|
|
2177
|
-
value: frozen,
|
|
2178
|
-
estimatedBytes: metrics.estimatedBytes,
|
|
2179
|
-
visitedNodes: metrics.visitedNodes,
|
|
2180
|
-
oversize: metrics.oversize
|
|
2181
|
-
};
|
|
2023
|
+
snapshot.value = freezeInner(value, 0, path, snapshot);
|
|
2024
|
+
return snapshot;
|
|
2182
2025
|
} catch {
|
|
2183
2026
|
return {
|
|
2184
2027
|
value: atom("unserializable"),
|
|
2185
2028
|
estimatedBytes: NODE + 16,
|
|
2186
|
-
visitedNodes: Math.max(1,
|
|
2029
|
+
visitedNodes: Math.max(1, snapshot.visitedNodes),
|
|
2187
2030
|
oversize: false
|
|
2188
2031
|
};
|
|
2189
2032
|
} finally {
|
|
2190
|
-
path.clear();
|
|
2033
|
+
if (path.size !== 0) path.clear();
|
|
2191
2034
|
if (!reentrant) freezing = false;
|
|
2192
2035
|
}
|
|
2193
2036
|
};
|
|
@@ -2253,7 +2096,7 @@ var jsonStringUtf8Bytes = (value) => {
|
|
|
2253
2096
|
}
|
|
2254
2097
|
return bytes;
|
|
2255
2098
|
};
|
|
2256
|
-
var
|
|
2099
|
+
var ownData = (value, key) => {
|
|
2257
2100
|
try {
|
|
2258
2101
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
2259
2102
|
if (descriptor && "value" in descriptor) return descriptor.value;
|
|
@@ -2275,11 +2118,12 @@ var jsonLiteralUtf8Bytes = (value) => {
|
|
|
2275
2118
|
case "string":
|
|
2276
2119
|
return jsonStringUtf8Bytes(value);
|
|
2277
2120
|
case "object": {
|
|
2121
|
+
if (isFrozenAtom(value)) return jsonLiteralUtf8Bytes(encodeFrozen(value));
|
|
2278
2122
|
if (Array.isArray(value)) {
|
|
2279
2123
|
let bytes2 = 2;
|
|
2280
2124
|
for (let index = 0; index < value.length; index++) {
|
|
2281
2125
|
if (index > 0) bytes2 += 1;
|
|
2282
|
-
bytes2 += jsonLiteralUtf8Bytes(
|
|
2126
|
+
bytes2 += jsonLiteralUtf8Bytes(ownData(value, index));
|
|
2283
2127
|
}
|
|
2284
2128
|
return bytes2;
|
|
2285
2129
|
}
|
|
@@ -2290,7 +2134,7 @@ var jsonLiteralUtf8Bytes = (value) => {
|
|
|
2290
2134
|
if (!first) bytes += 1;
|
|
2291
2135
|
first = false;
|
|
2292
2136
|
bytes += jsonStringUtf8Bytes(key) + 1;
|
|
2293
|
-
bytes += jsonLiteralUtf8Bytes(
|
|
2137
|
+
bytes += jsonLiteralUtf8Bytes(ownData(record, key));
|
|
2294
2138
|
}
|
|
2295
2139
|
return bytes;
|
|
2296
2140
|
}
|
|
@@ -2356,6 +2200,28 @@ var encodePlainObject = (value) => {
|
|
|
2356
2200
|
}
|
|
2357
2201
|
return encoded;
|
|
2358
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
|
+
};
|
|
2359
2225
|
var encodeAtom = (frozen) => {
|
|
2360
2226
|
const kind = frozen[FROZEN];
|
|
2361
2227
|
switch (kind) {
|
|
@@ -2425,8 +2291,10 @@ var encodeAtom = (frozen) => {
|
|
|
2425
2291
|
...frozen.serializedBytes === void 0 ? {} : { __serialized_bytes: frozen.serializedBytes },
|
|
2426
2292
|
...frozen.value === void 0 ? {} : { value: encodeFrozen(frozen.value) }
|
|
2427
2293
|
});
|
|
2294
|
+
case "record":
|
|
2295
|
+
return encodeRecord(frozen);
|
|
2428
2296
|
case "instance": {
|
|
2429
|
-
const fields =
|
|
2297
|
+
const fields = encodeFrozen(frozen.value);
|
|
2430
2298
|
const encoded = /* @__PURE__ */ Object.create(null);
|
|
2431
2299
|
if (typeof fields === "object" && fields !== null && !Array.isArray(fields)) {
|
|
2432
2300
|
for (const key of Object.keys(fields)) {
|
|
@@ -2453,7 +2321,8 @@ var encodeAtom = (frozen) => {
|
|
|
2453
2321
|
}
|
|
2454
2322
|
};
|
|
2455
2323
|
var encodeFrozen = (value) => {
|
|
2456
|
-
if (value ===
|
|
2324
|
+
if (value === RASPUTIN_REDACTED) return RASPUTIN_REDACTED;
|
|
2325
|
+
if (isFrozenRecord(value)) return encodeRecord(value);
|
|
2457
2326
|
if (isFrozenAtom(value)) return encodeAtom(value);
|
|
2458
2327
|
if (Array.isArray(value)) {
|
|
2459
2328
|
const items = new Array(value.length);
|
|
@@ -2603,6 +2472,7 @@ var warnIfMissingAsyncContextFrame = () => {
|
|
|
2603
2472
|
var DEFAULT_MAX_ACTIVE_MEMORY_BYTES = 64 * 1024 * 1024;
|
|
2604
2473
|
var DEFAULT_MAX_EXECUTION_HOLD_MS = 6e4;
|
|
2605
2474
|
var DEFAULT_MAX_RETAINED_ERROR_RECORDINGS = 32;
|
|
2475
|
+
var EMPTY_ARGS = [];
|
|
2606
2476
|
var phaseTimingEnabled = process.env.RASPUTIN_RECORDER_PHASE_TIMING === "1";
|
|
2607
2477
|
var manualFunctionDefinition = (value) => {
|
|
2608
2478
|
const located = /^(.+):([^:@]+)@(\d+):(\d+)$/.exec(value);
|
|
@@ -2621,7 +2491,7 @@ var normalizeFunctionDefinition = (value) => typeof value === "string" ? manualF
|
|
|
2621
2491
|
var elapsedMs2 = (startedAtNs, endedAtNs = process.hrtime.bigint()) => Number(endedAtNs - startedAtNs) / 1e6;
|
|
2622
2492
|
var roundedMilliseconds2 = (nanoseconds) => Math.round(Number(nanoseconds) / 1e6 * 1e4) / 1e4;
|
|
2623
2493
|
var addRecorderTime = (recording, nanoseconds) => {
|
|
2624
|
-
if (
|
|
2494
|
+
if (!phaseTimingEnabled || nanoseconds <= 0n) return;
|
|
2625
2495
|
recording.inlineRecorderTimeNs += nanoseconds;
|
|
2626
2496
|
};
|
|
2627
2497
|
var mapArrayLike = (args, map) => {
|
|
@@ -2637,7 +2507,7 @@ var notifyObserver = (observer, value) => {
|
|
|
2637
2507
|
} catch {
|
|
2638
2508
|
}
|
|
2639
2509
|
};
|
|
2640
|
-
var observeRecordedCallback = function
|
|
2510
|
+
var observeRecordedCallback = function __rasputinHandleRun__3(recording, recorderStartedAtNs, callback, onReturn, onThrow) {
|
|
2641
2511
|
const callbackStartedAtNs = phaseTimingEnabled ? process.hrtime.bigint() : recorderStartedAtNs;
|
|
2642
2512
|
const recordExitWork = (callbackEndedAtNs) => {
|
|
2643
2513
|
if (!phaseTimingEnabled) return;
|
|
@@ -2790,11 +2660,7 @@ var createExecutionRecorder = (options) => {
|
|
|
2790
2660
|
maxActiveMemoryBytes,
|
|
2791
2661
|
options.maxSerializedValueBytes ?? 16 * 1024
|
|
2792
2662
|
);
|
|
2793
|
-
const
|
|
2794
|
-
const serializer = createSafeSerializer({
|
|
2795
|
-
...options,
|
|
2796
|
-
...envSecretMatcher.needleCount > 0 ? { redactSecretValues: envSecretMatcher.redact } : {}
|
|
2797
|
-
});
|
|
2663
|
+
const serializer = createSafeSerializer(options);
|
|
2798
2664
|
const excludesSource = createSourceExclusionMatcher(options.excludeSources);
|
|
2799
2665
|
const journalPool = new ExecutionJournalPool(maxEventsPerExecution);
|
|
2800
2666
|
const plansByRuntimeId = [];
|
|
@@ -2843,15 +2709,11 @@ var createExecutionRecorder = (options) => {
|
|
|
2843
2709
|
stats.serializedValues++;
|
|
2844
2710
|
stats.serializedValueNodes += frozen.visitedNodes;
|
|
2845
2711
|
stats.serializedValueBytes += frozen.estimatedBytes;
|
|
2846
|
-
return
|
|
2847
|
-
value: frozen.value,
|
|
2848
|
-
bytes: frozen.estimatedBytes,
|
|
2849
|
-
visitedNodes: frozen.visitedNodes
|
|
2850
|
-
};
|
|
2712
|
+
return frozen;
|
|
2851
2713
|
};
|
|
2852
2714
|
const captureValue = (recording, value) => {
|
|
2853
2715
|
try {
|
|
2854
|
-
return memoryBudget.captureValue(recording.memory,
|
|
2716
|
+
return memoryBudget.captureValue(recording.memory, value, freezeAndCount);
|
|
2855
2717
|
} catch {
|
|
2856
2718
|
return { __rasputin_type: "unserializable" };
|
|
2857
2719
|
}
|
|
@@ -3014,7 +2876,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3014
2876
|
version: 4,
|
|
3015
2877
|
captureProfile: resolveCaptureProfile(recording, events, truncated, capture),
|
|
3016
2878
|
executionId: recording.executionId,
|
|
3017
|
-
startedAt: recording.
|
|
2879
|
+
startedAt: new Date(recording.startedAtMs).toISOString(),
|
|
3018
2880
|
durationMs: elapsedMs2(recording.startedAtNs, endedAtNs),
|
|
3019
2881
|
recorder: { inlineWallTimeMs: 0 },
|
|
3020
2882
|
execution: {
|
|
@@ -3048,7 +2910,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3048
2910
|
if (recording.evidenceDiscarded) return;
|
|
3049
2911
|
recording.evidenceDiscarded = true;
|
|
3050
2912
|
recording.cachedState = void 0;
|
|
3051
|
-
recording.repeatedCalls =
|
|
2913
|
+
recording.repeatedCalls = void 0;
|
|
3052
2914
|
recording.lateCapturedCallIds = void 0;
|
|
3053
2915
|
recording.capturedErrors = /* @__PURE__ */ new WeakMap();
|
|
3054
2916
|
if (recording.journal) {
|
|
@@ -3234,11 +3096,15 @@ var createExecutionRecorder = (options) => {
|
|
|
3234
3096
|
countDroppedEvents(recording, droppedBefore);
|
|
3235
3097
|
};
|
|
3236
3098
|
const repeatedCallGroup = (recording, plan, parentCallId) => {
|
|
3237
|
-
|
|
3238
|
-
|
|
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);
|
|
3239
3105
|
if (!slot) {
|
|
3240
3106
|
slot = {};
|
|
3241
|
-
slots
|
|
3107
|
+
slots.set(plan.runtimePlanId, slot);
|
|
3242
3108
|
}
|
|
3243
3109
|
if (parentCallId === void 0) {
|
|
3244
3110
|
if (!slot.root) slot.root = newRepeatedGroup(plan);
|
|
@@ -3388,10 +3254,10 @@ var createExecutionRecorder = (options) => {
|
|
|
3388
3254
|
} catch {
|
|
3389
3255
|
}
|
|
3390
3256
|
};
|
|
3391
|
-
const runStore = function
|
|
3257
|
+
const runStore = function __rasputinHandleRun__4(store, callback) {
|
|
3392
3258
|
if (!phaseTimingEnabled) return storage.run(store, callback);
|
|
3393
3259
|
const alsStartedAtNs = process.hrtime.bigint();
|
|
3394
|
-
return storage.run(store, function
|
|
3260
|
+
return storage.run(store, function __rasputinHandleRun__5() {
|
|
3395
3261
|
addPhase("alsNs", process.hrtime.bigint() - alsStartedAtNs);
|
|
3396
3262
|
return callback();
|
|
3397
3263
|
});
|
|
@@ -3403,7 +3269,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3403
3269
|
const recording = {
|
|
3404
3270
|
executionId: `${Date.now()}-${process.pid}-${++executionCounter}`,
|
|
3405
3271
|
storageGeneration: ++storageClock,
|
|
3406
|
-
|
|
3272
|
+
startedAtMs: Date.now(),
|
|
3407
3273
|
startedAtNs: recorderStartedAtNs,
|
|
3408
3274
|
inlineRecorderTimeNs: 0n,
|
|
3409
3275
|
execution: {
|
|
@@ -3411,7 +3277,6 @@ var createExecutionRecorder = (options) => {
|
|
|
3411
3277
|
...metadata.request ? { request: { ...metadata.request } } : {}
|
|
3412
3278
|
},
|
|
3413
3279
|
journal: void 0,
|
|
3414
|
-
repeatedCalls: [],
|
|
3415
3280
|
capturedErrors: /* @__PURE__ */ new WeakMap(),
|
|
3416
3281
|
nextCallId: 0,
|
|
3417
3282
|
inFlightCalls: 0,
|
|
@@ -3429,11 +3294,11 @@ var createExecutionRecorder = (options) => {
|
|
|
3429
3294
|
addRecorderTime(recording, process.hrtime.bigint() - recorderStartedAtNs);
|
|
3430
3295
|
const store = { recording };
|
|
3431
3296
|
return {
|
|
3432
|
-
run: function
|
|
3297
|
+
run: function __rasputinHandleRun__4(callback) {
|
|
3433
3298
|
let startedCallback = false;
|
|
3434
3299
|
try {
|
|
3435
3300
|
const runStartedAtNs = process.hrtime.bigint();
|
|
3436
|
-
return runStore(store, function
|
|
3301
|
+
return runStore(store, function __rasputinHandleRun__5() {
|
|
3437
3302
|
startedCallback = true;
|
|
3438
3303
|
addRecorderTime(recording, process.hrtime.bigint() - runStartedAtNs);
|
|
3439
3304
|
try {
|
|
@@ -3481,14 +3346,14 @@ var createExecutionRecorder = (options) => {
|
|
|
3481
3346
|
return void 0;
|
|
3482
3347
|
}
|
|
3483
3348
|
};
|
|
3484
|
-
const runPreparedFunctionFromStore = function
|
|
3349
|
+
const runPreparedFunctionFromStore = function __rasputinHandleRun__4(store, plan, args, callback, omitValues) {
|
|
3485
3350
|
let startedCallback = false;
|
|
3486
3351
|
try {
|
|
3487
3352
|
return runPreparedFunctionFromStoreInner(
|
|
3488
3353
|
store,
|
|
3489
3354
|
plan,
|
|
3490
3355
|
args,
|
|
3491
|
-
function
|
|
3356
|
+
function __rasputinHandleRun__5() {
|
|
3492
3357
|
startedCallback = true;
|
|
3493
3358
|
return callback();
|
|
3494
3359
|
},
|
|
@@ -3499,7 +3364,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3499
3364
|
return callback();
|
|
3500
3365
|
}
|
|
3501
3366
|
};
|
|
3502
|
-
const runPreparedFunctionFromStoreInner = function
|
|
3367
|
+
const runPreparedFunctionFromStoreInner = function __rasputinHandleRun__4(store, plan, args, callback, omitValues) {
|
|
3503
3368
|
const omitCallValues = omitValues === true || plan.omitCallValues;
|
|
3504
3369
|
if (!store) return callback();
|
|
3505
3370
|
if (plan.disabled) {
|
|
@@ -3520,7 +3385,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3520
3385
|
const recorderStartedAtNs = process.hrtime.bigint();
|
|
3521
3386
|
if (store.suppressCapture || plan.excluded) {
|
|
3522
3387
|
stats.functionCallsExcluded++;
|
|
3523
|
-
return runStore({ ...store, suppressCapture: true }, function
|
|
3388
|
+
return runStore({ ...store, suppressCapture: true }, function __rasputinHandleRun__5() {
|
|
3524
3389
|
addRecorderTime(store.recording, process.hrtime.bigint() - recorderStartedAtNs);
|
|
3525
3390
|
return callback();
|
|
3526
3391
|
});
|
|
@@ -3538,7 +3403,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3538
3403
|
if (group.observedCalls > maxCapturedCallsPerFunction) {
|
|
3539
3404
|
const startedAtNs2 = process.hrtime.bigint();
|
|
3540
3405
|
try {
|
|
3541
|
-
const result = runStore(store, function
|
|
3406
|
+
const result = runStore(store, function __rasputinHandleRun__5() {
|
|
3542
3407
|
return callback();
|
|
3543
3408
|
});
|
|
3544
3409
|
recordSuppressedCall(recording, group, parentCallId, startedAtNs2, process.hrtime.bigint());
|
|
@@ -3553,7 +3418,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3553
3418
|
const startedAtNs = process.hrtime.bigint();
|
|
3554
3419
|
if (!journal) {
|
|
3555
3420
|
memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
|
|
3556
|
-
return runStore(store, function
|
|
3421
|
+
return runStore(store, function __rasputinHandleRun__5() {
|
|
3557
3422
|
return observeRecordedCallback(
|
|
3558
3423
|
recording,
|
|
3559
3424
|
recorderStartedAtNs,
|
|
@@ -3572,7 +3437,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3572
3437
|
countDroppedEvents(recording, droppedBefore);
|
|
3573
3438
|
settleInFlight(recording);
|
|
3574
3439
|
};
|
|
3575
|
-
return runStore(store, function
|
|
3440
|
+
return runStore(store, function __rasputinHandleRun__5() {
|
|
3576
3441
|
return observeRecordedCallback(
|
|
3577
3442
|
recording,
|
|
3578
3443
|
recorderStartedAtNs,
|
|
@@ -3603,7 +3468,7 @@ var createExecutionRecorder = (options) => {
|
|
|
3603
3468
|
journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
|
|
3604
3469
|
} catch {
|
|
3605
3470
|
journal.dropCall();
|
|
3606
|
-
return runStore(store, function
|
|
3471
|
+
return runStore(store, function __rasputinHandleRun__5() {
|
|
3607
3472
|
return observeRecordedCallback(
|
|
3608
3473
|
recording,
|
|
3609
3474
|
recorderStartedAtNs,
|
|
@@ -3616,17 +3481,22 @@ var createExecutionRecorder = (options) => {
|
|
|
3616
3481
|
});
|
|
3617
3482
|
}
|
|
3618
3483
|
const callStore = { recording, currentCallId: callId };
|
|
3619
|
-
return runStore(callStore, function
|
|
3484
|
+
return runStore(callStore, function __rasputinHandleRun__5() {
|
|
3620
3485
|
return observeRecordedCallback(
|
|
3621
3486
|
recording,
|
|
3622
3487
|
recorderStartedAtNs,
|
|
3623
3488
|
callback,
|
|
3624
3489
|
(value) => {
|
|
3625
3490
|
if (recording.journal) {
|
|
3626
|
-
const
|
|
3627
|
-
const durationNs = process.hrtime.bigint() - startedAtNs;
|
|
3491
|
+
const endedAtNs = process.hrtime.bigint();
|
|
3628
3492
|
const returnValue = omitCallValues ? rasputinOmitted() : captureValue(recording, value);
|
|
3629
|
-
recording.journal.finishCall(
|
|
3493
|
+
recording.journal.finishCall(
|
|
3494
|
+
KIND_EXIT,
|
|
3495
|
+
callId,
|
|
3496
|
+
endedAtNs - recording.startedAtNs,
|
|
3497
|
+
endedAtNs - startedAtNs,
|
|
3498
|
+
returnValue
|
|
3499
|
+
);
|
|
3630
3500
|
stats.functionCallsCaptured++;
|
|
3631
3501
|
}
|
|
3632
3502
|
settleInFlight(recording);
|
|
@@ -3637,11 +3507,12 @@ var createExecutionRecorder = (options) => {
|
|
|
3637
3507
|
return;
|
|
3638
3508
|
}
|
|
3639
3509
|
const capturedError = serializedError(recording, error, callId);
|
|
3510
|
+
const endedAtNs = process.hrtime.bigint();
|
|
3640
3511
|
recording.journal.finishCall(
|
|
3641
3512
|
KIND_THROW,
|
|
3642
3513
|
callId,
|
|
3643
|
-
|
|
3644
|
-
|
|
3514
|
+
endedAtNs - recording.startedAtNs,
|
|
3515
|
+
endedAtNs - startedAtNs,
|
|
3645
3516
|
capturedError.value
|
|
3646
3517
|
);
|
|
3647
3518
|
stats.functionCallsCaptured++;
|
|
@@ -3651,62 +3522,189 @@ var createExecutionRecorder = (options) => {
|
|
|
3651
3522
|
);
|
|
3652
3523
|
});
|
|
3653
3524
|
};
|
|
3654
|
-
const noopHandle2 =
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
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) {
|
|
3669
3546
|
try {
|
|
3670
|
-
|
|
3547
|
+
if (this.status !== "failed") {
|
|
3548
|
+
this.status = "left";
|
|
3549
|
+
this.pendingReturn = value;
|
|
3550
|
+
}
|
|
3551
|
+
return value;
|
|
3671
3552
|
} catch {
|
|
3672
|
-
|
|
3553
|
+
return value;
|
|
3673
3554
|
}
|
|
3674
|
-
}
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
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);
|
|
3685
3601
|
}
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
}
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
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);
|
|
3693
3632
|
return value;
|
|
3694
|
-
}
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
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);
|
|
3700
3644
|
} else {
|
|
3701
|
-
expectStore(
|
|
3645
|
+
expectStore(this, this.activeStore);
|
|
3702
3646
|
}
|
|
3703
3647
|
return value;
|
|
3704
|
-
}
|
|
3705
|
-
|
|
3706
|
-
expectStore(active);
|
|
3707
|
-
enter(parent);
|
|
3648
|
+
} catch {
|
|
3649
|
+
return value;
|
|
3708
3650
|
}
|
|
3709
|
-
}
|
|
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;
|
|
3710
3708
|
};
|
|
3711
3709
|
const enterPreparedFunctionFromStore = (store, plan, args, omitValues) => {
|
|
3712
3710
|
if (!store) return noopHandle2;
|
|
@@ -3716,20 +3714,21 @@ var createExecutionRecorder = (options) => {
|
|
|
3716
3714
|
}
|
|
3717
3715
|
if (store.recording.finished) {
|
|
3718
3716
|
if (!store.recording.budgetExpired && !store.recording.evicted) return noopHandle2;
|
|
3719
|
-
const
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
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
|
+
);
|
|
3733
3732
|
}
|
|
3734
3733
|
stats.functionCallsObserved++;
|
|
3735
3734
|
const recording = store.recording;
|
|
@@ -3738,22 +3737,22 @@ var createExecutionRecorder = (options) => {
|
|
|
3738
3737
|
if (store.suppressCapture || plan.excluded) {
|
|
3739
3738
|
stats.functionCallsExcluded++;
|
|
3740
3739
|
const excludedStore = { ...store, suppressCapture: true };
|
|
3741
|
-
const
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
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;
|
|
3757
3756
|
}
|
|
3758
3757
|
recording.inFlightCalls++;
|
|
3759
3758
|
const group = repeatedCallGroup(recording, plan, parentCallId);
|
|
@@ -3763,127 +3762,64 @@ var createExecutionRecorder = (options) => {
|
|
|
3763
3762
|
if (group.observedCalls === 1) journal?.notePlan(plan.runtimePlanId);
|
|
3764
3763
|
} catch {
|
|
3765
3764
|
}
|
|
3766
|
-
let status = "open";
|
|
3767
|
-
let pendingReturn;
|
|
3768
|
-
let ended = false;
|
|
3769
3765
|
const startedAtNs = process.hrtime.bigint();
|
|
3770
3766
|
const parentStore = store;
|
|
3771
|
-
const uncaptured = bindStoreTransitions(parentStore, parentStore, recording, plan);
|
|
3772
|
-
const finishEnd = () => {
|
|
3773
|
-
if (ended) return;
|
|
3774
|
-
ended = true;
|
|
3775
|
-
settleInFlight(recording);
|
|
3776
|
-
uncaptured.restore();
|
|
3777
|
-
};
|
|
3778
|
-
const context = {
|
|
3779
|
-
run: uncaptured.run,
|
|
3780
|
-
suspend: uncaptured.suspend,
|
|
3781
|
-
resume: uncaptured.resume
|
|
3782
|
-
};
|
|
3783
3767
|
if (group.observedCalls > maxCapturedCallsPerFunction) {
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
captureCompletedThrow(
|
|
3797
|
-
recording,
|
|
3798
|
-
plan,
|
|
3799
|
-
liveArgs ?? args,
|
|
3800
|
-
parentCallId,
|
|
3801
|
-
startedAtNs,
|
|
3802
|
-
error
|
|
3803
|
-
);
|
|
3804
|
-
},
|
|
3805
|
-
end: () => {
|
|
3806
|
-
if (status !== "failed") {
|
|
3807
|
-
recordSuppressedCall(
|
|
3808
|
-
recording,
|
|
3809
|
-
group,
|
|
3810
|
-
parentCallId,
|
|
3811
|
-
startedAtNs,
|
|
3812
|
-
process.hrtime.bigint()
|
|
3813
|
-
);
|
|
3814
|
-
}
|
|
3815
|
-
finishEnd();
|
|
3816
|
-
},
|
|
3817
|
-
...context
|
|
3818
|
-
};
|
|
3768
|
+
return activateUncaptured(
|
|
3769
|
+
"suppressed",
|
|
3770
|
+
recording,
|
|
3771
|
+
parentStore,
|
|
3772
|
+
plan,
|
|
3773
|
+
args,
|
|
3774
|
+
omitCallValues,
|
|
3775
|
+
parentCallId,
|
|
3776
|
+
startedAtNs,
|
|
3777
|
+
group,
|
|
3778
|
+
false
|
|
3779
|
+
);
|
|
3819
3780
|
}
|
|
3820
|
-
const dropWithoutCapture = (onThrow) => {
|
|
3821
|
-
uncaptured.enterActive();
|
|
3822
|
-
return {
|
|
3823
|
-
leave: (value) => {
|
|
3824
|
-
if (status !== "failed") {
|
|
3825
|
-
status = "left";
|
|
3826
|
-
pendingReturn = value;
|
|
3827
|
-
}
|
|
3828
|
-
return value;
|
|
3829
|
-
},
|
|
3830
|
-
fail: (error) => {
|
|
3831
|
-
if (status === "failed") return;
|
|
3832
|
-
status = "failed";
|
|
3833
|
-
onThrow(error);
|
|
3834
|
-
},
|
|
3835
|
-
end: () => {
|
|
3836
|
-
if (status !== "failed") {
|
|
3837
|
-
const droppedBefore = recording.journal?.dropped ?? 0;
|
|
3838
|
-
recording.journal?.dropCall();
|
|
3839
|
-
countDroppedEvents(recording, droppedBefore);
|
|
3840
|
-
}
|
|
3841
|
-
finishEnd();
|
|
3842
|
-
},
|
|
3843
|
-
...context
|
|
3844
|
-
};
|
|
3845
|
-
};
|
|
3846
3781
|
if (!journal) {
|
|
3847
3782
|
memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes);
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
},
|
|
3861
|
-
end: finishEnd,
|
|
3862
|
-
...context
|
|
3863
|
-
};
|
|
3783
|
+
return activateUncaptured(
|
|
3784
|
+
"idle",
|
|
3785
|
+
recording,
|
|
3786
|
+
parentStore,
|
|
3787
|
+
plan,
|
|
3788
|
+
args,
|
|
3789
|
+
omitCallValues,
|
|
3790
|
+
parentCallId,
|
|
3791
|
+
startedAtNs,
|
|
3792
|
+
group,
|
|
3793
|
+
false
|
|
3794
|
+
);
|
|
3864
3795
|
}
|
|
3865
3796
|
if (!journal.canStartCall()) {
|
|
3866
|
-
return
|
|
3867
|
-
|
|
3868
|
-
|
|
3797
|
+
return activateUncaptured(
|
|
3798
|
+
"dropped",
|
|
3799
|
+
recording,
|
|
3800
|
+
parentStore,
|
|
3801
|
+
plan,
|
|
3802
|
+
args,
|
|
3803
|
+
omitCallValues,
|
|
3804
|
+
parentCallId,
|
|
3805
|
+
startedAtNs,
|
|
3806
|
+
group,
|
|
3807
|
+
true
|
|
3808
|
+
);
|
|
3869
3809
|
}
|
|
3870
3810
|
if (!memoryBudget.reserveCall(recording.memory, plan.estimatedCallBytes)) {
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
},
|
|
3884
|
-
end: finishEnd,
|
|
3885
|
-
...context
|
|
3886
|
-
};
|
|
3811
|
+
return activateUncaptured(
|
|
3812
|
+
"idle",
|
|
3813
|
+
recording,
|
|
3814
|
+
parentStore,
|
|
3815
|
+
plan,
|
|
3816
|
+
args,
|
|
3817
|
+
omitCallValues,
|
|
3818
|
+
parentCallId,
|
|
3819
|
+
startedAtNs,
|
|
3820
|
+
group,
|
|
3821
|
+
false
|
|
3822
|
+
);
|
|
3887
3823
|
}
|
|
3888
3824
|
const callId = ++recording.nextCallId;
|
|
3889
3825
|
const enterTimestampNs = process.hrtime.bigint() - recording.startedAtNs;
|
|
@@ -3892,65 +3828,36 @@ var createExecutionRecorder = (options) => {
|
|
|
3892
3828
|
journal.startCall(plan.runtimePlanId, callId, parentCallId, enterTimestampNs, capturedArgs);
|
|
3893
3829
|
} catch {
|
|
3894
3830
|
journal.dropCall();
|
|
3895
|
-
return
|
|
3896
|
-
|
|
3831
|
+
return activateUncaptured(
|
|
3832
|
+
"dropped",
|
|
3833
|
+
recording,
|
|
3834
|
+
parentStore,
|
|
3835
|
+
plan,
|
|
3836
|
+
args,
|
|
3837
|
+
omitCallValues,
|
|
3838
|
+
parentCallId,
|
|
3839
|
+
startedAtNs,
|
|
3840
|
+
group,
|
|
3841
|
+
false
|
|
3842
|
+
);
|
|
3897
3843
|
}
|
|
3898
3844
|
const callStore = { recording, currentCallId: callId };
|
|
3899
|
-
const captured =
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
KIND_THROW,
|
|
3916
|
-
callId,
|
|
3917
|
-
process.hrtime.bigint() - recording.startedAtNs,
|
|
3918
|
-
process.hrtime.bigint() - startedAtNs,
|
|
3919
|
-
capturedError.value
|
|
3920
|
-
);
|
|
3921
|
-
stats.functionCallsCaptured++;
|
|
3922
|
-
capturedError.commit();
|
|
3923
|
-
};
|
|
3924
|
-
return {
|
|
3925
|
-
leave: (value) => {
|
|
3926
|
-
if (status !== "failed") {
|
|
3927
|
-
status = "left";
|
|
3928
|
-
pendingReturn = value;
|
|
3929
|
-
}
|
|
3930
|
-
return value;
|
|
3931
|
-
},
|
|
3932
|
-
fail: (error) => {
|
|
3933
|
-
if (status === "failed") return;
|
|
3934
|
-
status = "failed";
|
|
3935
|
-
try {
|
|
3936
|
-
writeThrow(error);
|
|
3937
|
-
} catch {
|
|
3938
|
-
}
|
|
3939
|
-
},
|
|
3940
|
-
end: () => {
|
|
3941
|
-
try {
|
|
3942
|
-
if (status !== "failed") writeExit(status === "left" ? pendingReturn : void 0);
|
|
3943
|
-
} catch {
|
|
3944
|
-
}
|
|
3945
|
-
if (ended) return;
|
|
3946
|
-
ended = true;
|
|
3947
|
-
settleInFlight(recording);
|
|
3948
|
-
captured.restore();
|
|
3949
|
-
},
|
|
3950
|
-
run: captured.run,
|
|
3951
|
-
suspend: captured.suspend,
|
|
3952
|
-
resume: captured.resume
|
|
3953
|
-
};
|
|
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;
|
|
3954
3861
|
};
|
|
3955
3862
|
const runPreparedFunction = (plan, args, callback, omitValues) => {
|
|
3956
3863
|
const store = currentStore();
|
|
@@ -3959,51 +3866,13 @@ var createExecutionRecorder = (options) => {
|
|
|
3959
3866
|
}
|
|
3960
3867
|
return runPreparedFunctionFromStore(store, plan, args, callback, omitValues);
|
|
3961
3868
|
};
|
|
3962
|
-
const isolateHandle2 = (handle) => ({
|
|
3963
|
-
leave: (value) => {
|
|
3964
|
-
try {
|
|
3965
|
-
return handle.leave(value);
|
|
3966
|
-
} catch {
|
|
3967
|
-
return value;
|
|
3968
|
-
}
|
|
3969
|
-
},
|
|
3970
|
-
fail: (error, liveArgs) => {
|
|
3971
|
-
try {
|
|
3972
|
-
handle.fail(error, liveArgs);
|
|
3973
|
-
} catch {
|
|
3974
|
-
}
|
|
3975
|
-
},
|
|
3976
|
-
end: () => {
|
|
3977
|
-
try {
|
|
3978
|
-
handle.end();
|
|
3979
|
-
} catch {
|
|
3980
|
-
}
|
|
3981
|
-
},
|
|
3982
|
-
run: function __rasputinHandleRun__3(callback) {
|
|
3983
|
-
return runExactlyOnce((invoke) => handle.run(invoke), callback);
|
|
3984
|
-
},
|
|
3985
|
-
suspend: (value) => {
|
|
3986
|
-
try {
|
|
3987
|
-
return handle.suspend(value);
|
|
3988
|
-
} catch {
|
|
3989
|
-
return value;
|
|
3990
|
-
}
|
|
3991
|
-
},
|
|
3992
|
-
resume: (value) => {
|
|
3993
|
-
try {
|
|
3994
|
-
return handle.resume(value);
|
|
3995
|
-
} catch {
|
|
3996
|
-
return value;
|
|
3997
|
-
}
|
|
3998
|
-
}
|
|
3999
|
-
});
|
|
4000
3869
|
const enterPreparedFunction = (plan, args, omitValues) => {
|
|
4001
3870
|
try {
|
|
4002
3871
|
const store = currentStore();
|
|
4003
3872
|
if (store && !store.recording.finished && !store.recording.sawAutomatic) {
|
|
4004
3873
|
store.recording.sawAutomatic = true;
|
|
4005
3874
|
}
|
|
4006
|
-
return
|
|
3875
|
+
return enterPreparedFunctionFromStore(store, plan, args, omitValues);
|
|
4007
3876
|
} catch {
|
|
4008
3877
|
return noopHandle2;
|
|
4009
3878
|
}
|
|
@@ -4030,14 +3899,14 @@ var createExecutionRecorder = (options) => {
|
|
|
4030
3899
|
function trace(input, fn) {
|
|
4031
3900
|
const definition = typeof input === "string" ? manualFunctionDefinition(input) : { ...input, functionId: runtimeFunctionId2(input) };
|
|
4032
3901
|
const plan = preparePlan(definition);
|
|
4033
|
-
return function
|
|
3902
|
+
return function __rasputinHandleRun__4(...args) {
|
|
4034
3903
|
if (new.target) {
|
|
4035
3904
|
throw new TypeError("execution.trace() wraps function calls, not constructors");
|
|
4036
3905
|
}
|
|
4037
3906
|
const receiver = this;
|
|
4038
3907
|
const store = currentStore();
|
|
4039
3908
|
if (store && !store.recording.finished) store.recording.sawManual = true;
|
|
4040
|
-
return runPreparedFunctionFromStore(store, plan, args, function
|
|
3909
|
+
return runPreparedFunctionFromStore(store, plan, args, function __rasputinHandleRun__5() {
|
|
4041
3910
|
return fn.apply(receiver, args);
|
|
4042
3911
|
});
|
|
4043
3912
|
};
|
|
@@ -4073,9 +3942,7 @@ var bindExecution = (execution, module) => {
|
|
|
4073
3942
|
module.cell.enter = (planIndex, args, omitValues) => {
|
|
4074
3943
|
try {
|
|
4075
3944
|
const plan = prepared[planIndex];
|
|
4076
|
-
return
|
|
4077
|
-
plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughHandle()
|
|
4078
|
-
);
|
|
3945
|
+
return plan ? execution.enterPreparedFunction(plan, args, omitValues) : passthroughHandle();
|
|
4079
3946
|
} catch {
|
|
4080
3947
|
return passthroughHandle();
|
|
4081
3948
|
}
|