{"record":{"id":"3f7cc8b9cc633c66","repo":"facebook/flow","slug":"daemon-child-failed-to-write-token-to-parent-in-s","errorCode":null,"errorMessage":"Daemon child: failed to write token to parent in-socket: {}","messagePattern":"Daemon child: failed to write token to parent in-socket: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"rust_port/crates/flow_daemon/src/daemon.rs","lineNumber":566,"sourceCode":"        panic!(\n            \"Daemon child: failed to write token to parent out-socket: {}\",\n            e\n        )\n    });\n    let mut child_out_sock = TcpStream::connect(parent_in_addr).unwrap_or_else(|e| {\n        panic!(\n            \"Daemon child: failed to connect to parent in-socket (child write end): {}\",\n            e\n        )\n    });\n    child_out_sock.set_nodelay(true).unwrap_or_else(|e| {\n        panic!(\n            \"Daemon child: failed to set TCP_NODELAY on parent in-socket: {}\",\n            e\n        )\n    });\n    child_out_sock.write_all(&token).unwrap_or_else(|e| {\n        panic!(\n            \"Daemon child: failed to write token to parent in-socket: {}\",\n            e\n        )\n    });\n\n    exec(&entry_name, child_in_sock, child_out_sock, param_bytes);\n}\n\npub fn close<I, O>(h: &mut Handle<I, O>) -> std::io::Result<()> {\n    h.channels.0.stream.shutdown(std::net::Shutdown::Read)?;\n    h.channels.1.stream.shutdown(std::net::Shutdown::Write)?;\n    Ok(())\n}\n\npub fn close_noerr<I, O>(h: &mut Handle<I, O>) {\n    if let Err(e) = h.channels.0.stream.shutdown(std::net::Shutdown::Read) {\n        tracing::debug!(target: \"flow_daemon\", \"close_noerr (in): {}\", e);\n    }","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/rust_port/crates/flow_daemon/src/daemon.rs#L548-L584","documentation":"Final handshake step: the child writes the authentication token to the parent's in-socket (its write channel). write_all failing means that socket broke before or during the write: the parent closed its read end (gave up waiting, crashed) yielding EPIPE, or the loopback connection was reset mid-write.","triggerScenarios":"Parent times out or exits after accepting but before reading the second token write; connection reset by the OS; process tree torn down by a supervisor during the handshake.","commonSituations":"Heavily loaded or throttled machines stretching the two-write handshake past parent timeouts; OOM killing the parent mid-handshake; cleanup scripts killing daemon trees during spawn.","solutions":["Retry the command; one-off handshake races typically clear","Address load/memory pressure so the parent survives the full handshake","flow stop, then retry to start from clean daemon state","Inspect parent logs for early exit reasons if it repeats"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Retry the command; broken handshake pipes are usually one-off races","Address memory/load pressure so the parent survives the full two-socket handshake","Run flow stop before retrying to start from clean daemon state"],"tags":["daemon","socket","broken-pipe","handshake","spawn"],"backgroundTag":"broken-pipe","analyzedSha":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-08-23T11:17:13.642Z"}