mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-17 02:04:13 +00:00
feat: [US-042] - Handle CDP connection death on Chromium crash
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a9629c91ea
commit
c96558e523
4 changed files with 31 additions and 2 deletions
|
|
@ -158,6 +158,14 @@ impl CdpClient {
|
|||
rx
|
||||
}
|
||||
|
||||
/// Check whether the CDP WebSocket connection is still alive.
|
||||
///
|
||||
/// Returns `true` if the background reader task is still running, which
|
||||
/// means the WebSocket connection has not been closed or errored.
|
||||
pub fn is_alive(&self) -> bool {
|
||||
!self.reader_task.is_finished()
|
||||
}
|
||||
|
||||
/// Close the CDP connection and stop the reader task.
|
||||
pub async fn close(&self) {
|
||||
self.reader_task.abort();
|
||||
|
|
|
|||
|
|
@ -757,6 +757,17 @@ impl BrowserRuntime {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check CDP WebSocket connection is alive
|
||||
if let Some(ref cdp) = state.cdp_client {
|
||||
if !cdp.is_alive() {
|
||||
let problem =
|
||||
BrowserProblem::cdp_error("CDP WebSocket connection died unexpectedly");
|
||||
self.record_problem_locked(state, &problem);
|
||||
state.state = BrowserState::Failed;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn snapshot_locked(&self, state: &BrowserRuntimeStateData) -> BrowserStatusResponse {
|
||||
|
|
@ -910,7 +921,7 @@ impl BrowserRuntime {
|
|||
tty: false,
|
||||
interactive: false,
|
||||
owner: ProcessOwner::Desktop,
|
||||
restart_policy: Some(RestartPolicy::Always),
|
||||
restart_policy: Some(RestartPolicy::Never),
|
||||
})
|
||||
.await
|
||||
.map_err(|err| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue