mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 06:57:41 +00:00
fix: tune remote CDP timeouts
This commit is contained in:
@@ -187,13 +187,36 @@ function createProfileContext(
|
||||
};
|
||||
};
|
||||
|
||||
const isReachable = async (timeoutMs = 300) => {
|
||||
const wsTimeout = Math.max(200, Math.min(2000, timeoutMs * 2));
|
||||
return await isChromeCdpReady(profile.cdpUrl, timeoutMs, wsTimeout);
|
||||
const resolveRemoteHttpTimeout = (timeoutMs: number | undefined) => {
|
||||
if (profile.cdpIsLoopback) return timeoutMs ?? 300;
|
||||
const resolved = state().resolved;
|
||||
if (typeof timeoutMs === "number" && Number.isFinite(timeoutMs)) {
|
||||
return Math.max(Math.floor(timeoutMs), resolved.remoteCdpTimeoutMs);
|
||||
}
|
||||
return resolved.remoteCdpTimeoutMs;
|
||||
};
|
||||
|
||||
const isHttpReachable = async (timeoutMs = 300) => {
|
||||
return await isChromeReachable(profile.cdpUrl, timeoutMs);
|
||||
const resolveRemoteWsTimeout = (timeoutMs: number | undefined) => {
|
||||
if (profile.cdpIsLoopback) {
|
||||
const base = timeoutMs ?? 300;
|
||||
return Math.max(200, Math.min(2000, base * 2));
|
||||
}
|
||||
const resolved = state().resolved;
|
||||
if (typeof timeoutMs === "number" && Number.isFinite(timeoutMs)) {
|
||||
return Math.max(Math.floor(timeoutMs) * 2, resolved.remoteCdpHandshakeTimeoutMs);
|
||||
}
|
||||
return resolved.remoteCdpHandshakeTimeoutMs;
|
||||
};
|
||||
|
||||
const isReachable = async (timeoutMs?: number) => {
|
||||
const httpTimeout = resolveRemoteHttpTimeout(timeoutMs);
|
||||
const wsTimeout = resolveRemoteWsTimeout(timeoutMs);
|
||||
return await isChromeCdpReady(profile.cdpUrl, httpTimeout, wsTimeout);
|
||||
};
|
||||
|
||||
const isHttpReachable = async (timeoutMs?: number) => {
|
||||
const httpTimeout = resolveRemoteHttpTimeout(timeoutMs);
|
||||
return await isChromeReachable(profile.cdpUrl, httpTimeout);
|
||||
};
|
||||
|
||||
const attachRunning = (running: NonNullable<ProfileRuntimeState["running"]>) => {
|
||||
|
||||
Reference in New Issue
Block a user