fix(browser): preserve raw chrome launch diagnostics

This commit is contained in:
Vincent Koc
2026-05-17 02:47:58 +08:00
parent 82e8b5232d
commit 55e4b76bb2
2 changed files with 15 additions and 5 deletions

View File

@@ -517,6 +517,16 @@ describe("chrome.ts internal", () => {
});
it("clears stale singleton locks and retries once after profile-in-use launch failure", async () => {
const configPath = path.join(tmpDir, "openclaw.json");
await fsp.writeFile(
configPath,
JSON.stringify({
logging: {
redactPatterns: ["profile appears to be in use by another Chromium process"],
},
}),
);
vi.stubEnv("OPENCLAW_CONFIG_PATH", configPath);
let cdpReachable = false;
vi.stubGlobal(
"fetch",

View File

@@ -542,9 +542,9 @@ export async function launchOpenClawChrome(
const diagnosticText = await diagnoseChromeCdp(profile.cdpUrl)
.then(formatChromeCdpDiagnostic)
.catch((err) => `CDP diagnostic failed: ${safeChromeCdpErrorMessage(err)}.`);
const stderrOutput = redactSensitiveText(
normalizeOptionalString(Buffer.concat(stderrChunks).toString("utf8")) ?? "",
);
const stderrOutput =
normalizeOptionalString(Buffer.concat(stderrChunks).toString("utf8")) ?? "";
const redactedStderrOutput = redactSensitiveText(stderrOutput);
if (
allowSingletonRecovery &&
CHROME_SINGLETON_IN_USE_PATTERN.test(stderrOutput) &&
@@ -556,8 +556,8 @@ export async function launchOpenClawChrome(
await terminateChromeForRetry(proc, userDataDir);
return await launchOnceAndWait(false);
}
const stderrHint = stderrOutput
? `\nChrome stderr:\n${stderrOutput.slice(0, CHROME_STDERR_HINT_MAX_CHARS)}`
const stderrHint = redactedStderrOutput
? `\nChrome stderr:\n${redactedStderrOutput.slice(0, CHROME_STDERR_HINT_MAX_CHARS)}`
: "";
const launchHints = chromeLaunchHints({ stderrOutput, resolved, profile, launchOptions });
try {