{"record":{"id":"4c2dd8f035b06378","repo":"jlcodes99/cockpit-tools","slug":"timedout-4c2dd8","errorCode":"TimedOut","errorMessage":"PowerShell 进程探测超时（{}ms）","messagePattern":"PowerShell 进程探测超时（(.+?)ms）","errorType":"error_code","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/modules/process_launch_candidates.rs","lineNumber":488,"sourceCode":"            if let Some(mut out) = child.stdout.take() {\n                let _ = out.read_to_end(&mut stdout);\n            }\n            if let Some(mut err) = child.stderr.take() {\n                let _ = err.read_to_end(&mut stderr);\n            }\n            let result = Ok(std::process::Output {\n                status,\n                stdout,\n                stderr,\n            });\n            log_command_trace_result(&preview, &result, start.elapsed());\n            return result;\n        }\n\n        if start.elapsed() >= timeout {\n            let _ = child.kill();\n            let _ = child.wait();\n            let result = Err(Error::new(\n                ErrorKind::TimedOut,\n                format!(\"PowerShell 进程探测超时（{}ms）\", timeout.as_millis()),\n            ));\n            log_command_trace_result(&preview, &result, start.elapsed());\n            return result;\n        }\n\n        thread::sleep(Duration::from_millis(100));\n    }\n}\n\n#[cfg(target_os = \"windows\")]\nfn cmd_output(args: &[&str]) -> std::io::Result<std::process::Output> {\n    use std::os::windows::process::CommandExt;\n\n    let mut command = Command::new(\"cmd\");\n    command.creation_flags(CREATE_NO_WINDOW).args(args);\n    let preview = format_command_preview(&command);","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src-tauri/src/modules/process_launch_candidates.rs#L470-L506","documentation":"powershell_output_with_timeout spawns a PowerShell process to probe running processes and enforces a wall-clock timeout. If the child does not finish within the timeout, it is killed and an io::Error of kind TimedOut is returned with the elapsed milliseconds in the message. Callers use it to enumerate codex/antigravity/codebuddy processes on Windows.","triggerScenarios":"Calling any of the collectors (collect_codex_process_entries_from_powershell, collect_antigravity_process_entries_from_powershell, collect_codebuddy_process_entries_from_powershell, close_processes_by_exact_exe_paths, collect_codex_windows_resource_process_pids) when the spawned PowerShell child exceeds the configured timeout.","commonSituations":"Slow or loaded Windows machines, PowerShell cold-start/profile-loading delays, antivirus scanning powershell.exe, Get-CimInstance queries hanging under system pressure.","solutions":["Increase the timeout passed to powershell_output_with_timeout if the machine is known to be slow.","Retry the probe once; transient stalls often resolve on a second attempt.","Add -NoProfile -NonInteractive to the PowerShell invocation to avoid profile-load delays.","Check system load / antivirus interference with powershell.exe and WMI/CIM service health."],"exampleFix":"// before\nlet out = powershell_output_with_timeout(&cmd, Duration::from_secs(5))?;\n\n// after\nmatch powershell_output_with_timeout(&cmd, Duration::from_secs(15)) {\n    Ok(out) => out,\n    Err(e) if e.kind() == std::io::ErrorKind::TimedOut => {\n        log::warn!(\"powershell probe timed out; retrying once\");\n        powershell_output_with_timeout(&cmd, Duration::from_secs(15))?\n    }\n    Err(e) => return Err(e),\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match powershell_output_with_timeout(&cmd, timeout) {\n    Err(e) if e.kind() == std::io::ErrorKind::TimedOut => retry_with_longer_timeout(),\n    other => other,\n}","preventionTips":["Invoke PowerShell with -NoProfile -NonInteractive to avoid startup delays","Budget timeouts for slow machines and antivirus scanning of powershell.exe","Retry transient timeouts once before surfacing an error","Keep WMI/CIM services healthy on Windows probes"],"tags":["timeout","powershell","process","windows"],"backgroundTag":"process-timeout","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}