{"record":{"id":"97c84dd5ad96ef35","repo":"Hmbown/CodeWhale","slug":"lane-was-stopped-before-inline-start-complete","errorCode":null,"errorMessage":"lane `{}` was stopped before inline start completed","messagePattern":"lane `(.+?)` was stopped before inline start completed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/lane/src/runtime.rs","lineNumber":969,"sourceCode":"        registry: &LaneRegistry,\n        record: &mut LaneRecord,\n        spec: &LaneStartSpec,\n    ) -> Result<()> {\n        if spec.command.is_empty() {\n            bail!(\"inline runtime requires a non-empty command\");\n        }\n        let cwd = apply_worktree(record, spec)?;\n        append_log_event(\n            &record.log_path,\n            serde_json::json!({\n                \"type\": \"lane_started\",\n                \"lane_id\": record.id,\n                \"runtime\": \"inline\",\n                \"command\": spec.command,\n            }),\n        )?;\n        if !registry.mark_running_if_pending(record)? {\n            bail!(\n                \"lane `{}` was stopped before inline start completed\",\n                record.id\n            );\n        }\n\n        let mut cmd = Command::new(&spec.command[0]);\n        if spec.command.len() > 1 {\n            cmd.args(&spec.command[1..]);\n        }\n        if let Some(cwd) = cwd.as_ref() {\n            cmd.current_dir(cwd);\n        }\n        cmd.envs(spec.environment.iter().map(|(key, value)| (key, value)));\n        cmd.stdout(Stdio::piped()).stderr(Stdio::piped());\n        let mut child = match cmd.spawn() {\n            Ok(child) => child,\n            Err(err) => {\n                append_log_event(","sourceCodeStart":951,"sourceCodeEnd":987,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/lane/src/runtime.rs#L951-L987","documentation":"Raised by the inline lane runtime's `start` in crates/lane/src/runtime.rs after the lane record was written as pending: `mark_running_if_pending` returned false, meaning the lane's status was flipped out of Pending concurrently before the inline process could be launched. The library treats this as a lost race — the lane was stopped (or otherwise transitioned) while start was in flight, so the process must not be spawned.","triggerScenarios":"Calling `start` on an inline-runtime lane whose registry record is concurrently transitioned from Pending to Stopped by another thread/process (e.g. a stop call racing the start). It fires exactly when `registry.mark_running_if_pending(record)` returns false.","commonSituations":"Two agents/tools driving the same lane: one runs start while another issues stop; a watchdog or TTL cleanup stops a just-created pending lane; a script retries start after a previous slow start finally completed and was torn down.","solutions":["Re-issue the start once the racing stop has settled; check the lane's current status first.","Serialize start/stop for the same lane (a mutex or task queue per lane id) instead of calling both concurrently.","If the stop was intentional, do not restart; treat this error as confirmation the lane was torn down."],"exampleFix":"// before: racing\nlet start_h = tokio::spawn(async { runtime.start(&spec).await });\nregistry.stop(id)?;\n// after: serialized\nlet start_h = tokio::spawn(async { runtime.start(&spec).await });\nlet started = start_h.await??;\nregistry.stop(id)?;","handlingStrategy":"try-catch","validationCode":"// Rust: check state before starting\nlet record = registry.get(id)?;\nif record.status != LaneStatus::Pending { /* re-create or skip */ }","typeGuard":"fn startable(record: &LaneRecord) -> bool { record.status == LaneStatus::Pending }","tryCatchPattern":"match runtime.start(&spec) {\n    Err(e) if e.to_string().contains(\"stopped before inline start completed\") => {\n        // lost race with stop: re-check status, restart or surface\n    }\n    other => other?,\n}","preventionTips":["Serialize per-lane start/stop through a single owner (mutex or actor).","Re-check lane status after any concurrent stop signal before starting.","Avoid fire-and-forget stop calls issued while a start is in flight."],"tags":["lane","race-condition","state-machine"],"backgroundTag":"invalid-state-transition","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}