fix: 为 WebProbe 增加物理内存门禁
This commit is contained in:
@@ -797,6 +797,23 @@ function digestSessionRail(value) {
|
||||
|
||||
async function captureScreenshot(reason, imageType = "png") {
|
||||
if (!page || page.isClosed()) throw new Error("page is not available for screenshot");
|
||||
if (screenshotCount >= maxScreenshots) {
|
||||
lastScreenshotAtMs = Date.now();
|
||||
return {
|
||||
seq: null,
|
||||
sampleSeq,
|
||||
ts: new Date().toISOString(),
|
||||
kind: "screenshot-skipped",
|
||||
reason,
|
||||
skipped: true,
|
||||
skipReason: "screenshot-cap-reached",
|
||||
screenshotCount,
|
||||
maxScreenshots,
|
||||
pageId,
|
||||
currentUrl: currentPageUrl(),
|
||||
valuesRedacted: true,
|
||||
};
|
||||
}
|
||||
if (screenshotCaptureState && screenshotCaptureState.settled !== true) {
|
||||
const ageMs = Date.now() - Number(screenshotCaptureState.startedAtMs || Date.now());
|
||||
const error = new Error("screenshot capture already in progress");
|
||||
@@ -814,6 +831,7 @@ async function captureScreenshot(reason, imageType = "png") {
|
||||
lastScreenshotAtMs = Date.now();
|
||||
throw error;
|
||||
}
|
||||
screenshotCount += 1;
|
||||
artifactSeq += 1;
|
||||
const safeReason = safeId(String(reason || "manual")).slice(0, 40) || "manual";
|
||||
const type = imageType === "jpeg" || imageType === "jpg" ? "jpeg" : "png";
|
||||
@@ -888,7 +906,7 @@ async function summarizeWorkbenchResponseBody(response, request) {
|
||||
const contentType = String(headers["content-type"] || headers["Content-Type"] || "");
|
||||
if (!/json/iu.test(contentType)) return { bodyRead: false, bodyReadSkipped: "non-json", valuesRedacted: true };
|
||||
const contentLength = Number(headers["content-length"] || headers["Content-Length"]);
|
||||
const maxBytes = 512 * 1024;
|
||||
const maxBytes = responseBodyMaxBytes;
|
||||
if (Number.isFinite(contentLength) && contentLength > maxBytes) return { bodyRead: false, bodyReadSkipped: "content-length-too-large", bodyByteCount: contentLength, valuesRedacted: true };
|
||||
const text = await response.text();
|
||||
const byteCount = Buffer.byteLength(text);
|
||||
|
||||
Reference in New Issue
Block a user