fix: read async web probe reports from file
This commit is contained in:
@@ -5149,7 +5149,12 @@ function runNodeWebProbeAsync(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
const poll = pollNodeWebProbeJob(options, spec, jobId);
|
const poll = pollNodeWebProbeJob(options, spec, jobId);
|
||||||
const report = record(record(poll.status).report);
|
const statusReport = record(record(poll.status).report);
|
||||||
|
const reportPath = typeof start.reportPath === "string" ? start.reportPath : null;
|
||||||
|
const reportLoad = Object.keys(statusReport).length > 0
|
||||||
|
? { source: "status", report: statusReport, result: null as CommandResult | null, degradedReason: null as string | null, path: null as string | null }
|
||||||
|
: readNodeWebProbeReport(options, spec, reportPath);
|
||||||
|
const report = reportLoad.report ?? {};
|
||||||
const probe = compactWebProbeResult(Object.keys(report).length > 0 ? report : null);
|
const probe = compactWebProbeResult(Object.keys(report).length > 0 ? report : null);
|
||||||
const passed = probe?.status === "pass";
|
const passed = probe?.status === "pass";
|
||||||
const summary = nullableRecord(probe?.summary);
|
const summary = nullableRecord(probe?.summary);
|
||||||
@@ -5158,8 +5163,8 @@ function runNodeWebProbeAsync(
|
|||||||
: typeof probe?.degradedReason === "string"
|
: typeof probe?.degradedReason === "string"
|
||||||
? probe.degradedReason
|
? probe.degradedReason
|
||||||
: poll.status === null
|
: poll.status === null
|
||||||
? "web-probe-async-status-failed"
|
? reportLoad.degradedReason ?? "web-probe-async-status-failed"
|
||||||
: null;
|
: reportLoad.degradedReason;
|
||||||
return {
|
return {
|
||||||
ok: passed,
|
ok: passed,
|
||||||
status: passed ? "pass" : "blocked",
|
status: passed ? "pass" : "blocked",
|
||||||
@@ -5191,10 +5196,39 @@ function runNodeWebProbeAsync(
|
|||||||
screenshotPath: start.screenshotPath ?? null,
|
screenshotPath: start.screenshotPath ?? null,
|
||||||
},
|
},
|
||||||
statusResult: poll.result === null ? null : compactCommandResult(poll.result),
|
statusResult: poll.result === null ? null : compactCommandResult(poll.result),
|
||||||
|
reportLoad: {
|
||||||
|
source: reportLoad.source,
|
||||||
|
path: reportLoad.path,
|
||||||
|
result: reportLoad.result === null ? null : compactCommandResult(reportLoad.result),
|
||||||
|
degradedReason: reportLoad.degradedReason,
|
||||||
|
},
|
||||||
valuesRedacted: true,
|
valuesRedacted: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readNodeWebProbeReport(
|
||||||
|
options: NodeWebProbeRunOptions,
|
||||||
|
spec: HwlabRuntimeLaneSpec,
|
||||||
|
reportPath: string | null,
|
||||||
|
): { source: string; report: Record<string, unknown> | null; result: CommandResult | null; degradedReason: string | null; path: string | null } {
|
||||||
|
if (!reportPath) return { source: "missing", report: null, result: null, degradedReason: "web-probe-report-path-missing", path: null };
|
||||||
|
if (!isSafeWebProbeReportPath(reportPath)) return { source: "unsafe-path", report: null, result: null, degradedReason: "web-probe-report-path-invalid", path: reportPath };
|
||||||
|
const result = runTransWorkspaceStdinScript(options.node, spec.workspace, `cat ${shellQuote(reportPath)}`, 55);
|
||||||
|
if (result.exitCode !== 0 || result.timedOut) return { source: "report-file", report: null, result, degradedReason: result.timedOut ? "web-probe-command-timeout" : "web-probe-report-read-failed", path: reportPath };
|
||||||
|
const report = parseJsonObject(result.stdout);
|
||||||
|
return {
|
||||||
|
source: "report-file",
|
||||||
|
report,
|
||||||
|
result,
|
||||||
|
degradedReason: report === null ? "web-probe-report-parse-failed" : null,
|
||||||
|
path: reportPath,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSafeWebProbeReportPath(reportPath: string): boolean {
|
||||||
|
return reportPath.includes("/.state/web-live-dom-probe/") && reportPath.endsWith(".result.json") && !reportPath.includes("\0");
|
||||||
|
}
|
||||||
|
|
||||||
function pollNodeWebProbeJob(options: NodeWebProbeRunOptions, spec: HwlabRuntimeLaneSpec, jobId: string): {
|
function pollNodeWebProbeJob(options: NodeWebProbeRunOptions, spec: HwlabRuntimeLaneSpec, jobId: string): {
|
||||||
status: Record<string, unknown> | null;
|
status: Record<string, unknown> | null;
|
||||||
result: CommandResult | null;
|
result: CommandResult | null;
|
||||||
@@ -10065,6 +10099,8 @@ function compactWebProbeTraceSamples(value: unknown): Record<string, unknown>[]
|
|||||||
rowCount: sample.rowCount ?? null,
|
rowCount: sample.rowCount ?? null,
|
||||||
emptyLabel: sample.emptyLabel ?? null,
|
emptyLabel: sample.emptyLabel ?? null,
|
||||||
latestRowPreview: sample.latestRowPreview ?? null,
|
latestRowPreview: sample.latestRowPreview ?? null,
|
||||||
|
userVisibleRowCount: sample.userVisibleRowCount ?? null,
|
||||||
|
latestUserVisibleRowPreview: sample.latestUserVisibleRowPreview ?? null,
|
||||||
conversationId: sample.conversationId ?? null,
|
conversationId: sample.conversationId ?? null,
|
||||||
sessionId: sample.sessionId ?? null,
|
sessionId: sample.sessionId ?? null,
|
||||||
traceId: sample.traceId ?? null,
|
traceId: sample.traceId ?? null,
|
||||||
|
|||||||
Reference in New Issue
Block a user