fix(browser): harden CDP readiness

This commit is contained in:
Peter Steinberger
2026-01-01 16:15:12 +00:00
parent 9f704d7aa7
commit 538c1eb660
7 changed files with 269 additions and 27 deletions

View File

@@ -15,11 +15,16 @@ export function registerBrowserBasicRoutes(
return jsonError(res, 503, "browser server not started");
}
const reachable = await ctx.isReachable(300);
const [cdpHttp, cdpReady] = await Promise.all([
ctx.isHttpReachable(300),
ctx.isReachable(600),
]);
res.json({
enabled: current.resolved.enabled,
controlUrl: current.resolved.controlUrl,
running: reachable,
running: cdpReady,
cdpReady,
cdpHttp,
pid: current.running?.pid ?? null,
cdpPort: current.cdpPort,
chosenBrowser: current.running?.exe.kind ?? null,
@@ -47,4 +52,13 @@ export function registerBrowserBasicRoutes(
jsonError(res, 500, String(err));
}
});
app.post("/reset-profile", async (_req, res) => {
try {
const result = await ctx.resetProfile();
res.json({ ok: true, ...result });
} catch (err) {
jsonError(res, 500, String(err));
}
});
}