fix(cli): fix cli connection timeout to dev server (fix #6045) (#6046)

Fix tauri-cli connection to dev server stucks and waits for TCP timeout.
This commit is contained in:
KurikoMoe
2023-05-12 20:01:24 +08:00
committed by GitHub
parent a08d1b248f
commit fb485d25a0

View File

@@ -278,11 +278,15 @@ fn command_internal(mut options: Options) -> Result<()> {
};
let mut i = 0;
let sleep_interval = std::time::Duration::from_secs(2);
let timeout_duration = std::time::Duration::from_secs(1);
let max_attempts = 90;
loop {
if std::net::TcpStream::connect(addrs).is_ok() {
break;
'waiting: loop {
for addr in addrs.iter() {
if std::net::TcpStream::connect_timeout(addr, timeout_duration).is_ok() {
break 'waiting;
}
}
if i % 3 == 1 {
warn!(
"Waiting for your frontend dev server to start on {}...",