support consecutive --auto-connect commands (#786)
This commit is contained in:
@@ -872,9 +872,9 @@ async fn handle_launch(cmd: &Value, state: &mut DaemonState) -> Result<Value, St
|
|||||||
|
|
||||||
// Relaunch logic: check if we can reuse the existing connection
|
// Relaunch logic: check if we can reuse the existing connection
|
||||||
let needs_relaunch = if let Some(ref mgr) = state.browser {
|
let needs_relaunch = if let Some(ref mgr) = state.browser {
|
||||||
let has_cdp_arg = cdp_url.is_some() || cdp_port.is_some();
|
let is_external = cdp_url.is_some() || cdp_port.is_some() || auto_connect;
|
||||||
let was_cdp = mgr.is_cdp_connection();
|
let was_external = mgr.is_cdp_connection();
|
||||||
has_cdp_arg != was_cdp || !mgr.is_connection_alive().await
|
is_external != was_external || !mgr.is_connection_alive().await
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -609,10 +609,15 @@ impl BrowserManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn close(&mut self) -> Result<(), String> {
|
pub async fn close(&mut self) -> Result<(), String> {
|
||||||
let _ = self
|
if self.browser_process.is_some() {
|
||||||
.client
|
// Only send Browser.close when we launched the browser ourselves.
|
||||||
.send_command_no_params("Browser.close", None)
|
// For external connections (--auto-connect, --cdp) we just disconnect
|
||||||
.await;
|
// without shutting down the user's browser.
|
||||||
|
let _ = self
|
||||||
|
.client
|
||||||
|
.send_command_no_params("Browser.close", None)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(mut process) = self.browser_process.take() {
|
if let Some(mut process) = self.browser_process.take() {
|
||||||
let timeout = std::time::Duration::from_secs(5);
|
let timeout = std::time::Duration::from_secs(5);
|
||||||
|
|||||||
Reference in New Issue
Block a user