{"record":{"id":"630d7121f2153ef5","repo":"zed-industries/zed","slug":"subprocess-reported-error-during-start-message","errorCode":null,"errorMessage":"Subprocess reported error during start: {message}","messagePattern":"Subprocess reported error during start: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/etw_tracing/etw_tracing.rs","lineNumber":629,"sourceCode":"        bail!(\"ShellExecuteW failed to launch elevated process (code: {result_code})\");\n    }\n\n    let (stream, _) = listener.accept().context(\"Accept subprocess connection\")?;\n\n    let mut session = EtwSession {\n        output_path: output_path.to_path_buf(),\n        stream: BufReader::new(stream),\n        listener,\n        socket_path: sock_path,\n    };\n\n    let status: StatusMessage =\n        recv_json(&mut session.stream).context(\"Wait for Started status\")?;\n\n    match status {\n        StatusMessage::Started => {}\n        StatusMessage::Error { message } => {\n            bail!(\"Subprocess reported error during start: {message}\");\n        }\n        other => {\n            bail!(\"Unexpected status from subprocess: {other:?}\");\n        }\n    }\n\n    Ok(session)\n}\n\n#[derive(Debug, serde::Serialize, serde::Deserialize)]\n#[serde(tag = \"type\")]\npub enum StatusMessage {\n    Started,\n    Stopped,\n    TimedOut,\n    Cancelled,\n    Error { message: String },\n}","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/etw_tracing/etw_tracing.rs#L611-L647","documentation":"Thrown by launch_etw_recording() in Zed's etw_tracing crate (Windows-only ETW profiling). Zed re-launches its own exe elevated via ShellExecuteW(\"runas\") with --record-etw-trace; the elevated child connects back over an AF_UNIX socket and must send StatusMessage::Started as its first JSON line. Instead it sent StatusMessage::Error{message}, meaning the child failed inside record_etw_trace before the WPR recording started (COM init, building the WPR profile collection, creating IControlManager, or control_manager.Start). The {message} field is the child's full anyhow error chain and contains the real cause.","triggerScenarios":"Calling launch_etw_recording(heap_pid, output_path) (Zed's ETW/latency trace recording entry point) where the elevated subprocess fails at CoInitializeEx, build_profile_collection (e.g. invalid/unspawnable heap_pid profile), create_wpr, or 'Start WPR recording'. The child serializes its failure as {\"type\":\"Error\",\"message\":\"...\"} and the parent bails with this message.","commonSituations":"WPR (Windows Performance Recorder) API refusing to start a session, leftover ETW sessions with the same name, COM initialization failure in the elevated context, heap_pid pointing at a dead process when the profile is built, or the output path being unwritable. The actionable detail is always inside {message}, not this outer wrapper.","solutions":["Read the full error chain in {message} - it names the exact failing step (e.g. 'Start WPR recording') and the underlying HRESULT","Cancel leftover WPR/ETW sessions: run 'wpr -cancel' (or reboot) to clear kernel buffer sessions leaked by a previous recording","Retry the recording; transient WPR start failures are common after abrupt termination of an earlier session","Verify the target process pid is alive if you triggered heap-specific profiling (heap_pid)","Report a Zed bug with the inner {message} if Start WPR recording fails consistently on a healthy machine"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Treat ETW launch as fallible and always surface the inner message\nmatch launch_etw_recording(heap_pid, output_path) {\n    Ok(session) => { /* proceed */ }\n    Err(err) => {\n        // err's Display already embeds the subprocess's {message}\n        log::warn!(\"ETW recording failed to start: {err:#}\");\n        show_user_error(err);\n    }\n}","preventionTips":["Parse the inner {message} to distinguish WPR-start failures from COM/profile failures before suggesting fixes","Run recordings from a healthy elevated context and cancel leftover WPR sessions before starting a new one","Wrap ETW launch in UI code that reports the full anyhow chain, not just the outer bail text"],"tags":["windows","etw","wpr","elevated-process","profiling","ipc"],"backgroundTag":"subprocess-startup-failure","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}