Hmbown/CodeWhale · error

lane ` ` was stopped before inline start completed

Error message

lane `{}` was stopped before inline start completed

What it means

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.

Solutions

  1. Re-issue the start once the racing stop has settled; check the lane's current status first.
  2. Serialize start/stop for the same lane (a mutex or task queue per lane id) instead of calling both concurrently.
  3. If the stop was intentional, do not restart; treat this error as confirmation the lane was torn down.

Example fix

// before: racing
let start_h = tokio::spawn(async { runtime.start(&spec).await });
registry.stop(id)?;
// after: serialized
let start_h = tokio::spawn(async { runtime.start(&spec).await });
let started = start_h.await??;
registry.stop(id)?;
Defensive patterns

Strategy: try-catch

Validate before calling

// Rust: check state before starting
let record = registry.get(id)?;
if record.status != LaneStatus::Pending { /* re-create or skip */ }

Type guard

fn startable(record: &LaneRecord) -> bool { record.status == LaneStatus::Pending }

Try / catch

match runtime.start(&spec) {
    Err(e) if e.to_string().contains("stopped before inline start completed") => {
        // lost race with stop: re-check status, restart or surface
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/97c84dd5ad96ef35. Report an issue: GitHub.

Appendix: source

Thrown at crates/lane/src/runtime.rs:969

        registry: &LaneRegistry,
        record: &mut LaneRecord,
        spec: &LaneStartSpec,
    ) -> Result<()> {
        if spec.command.is_empty() {
            bail!("inline runtime requires a non-empty command");
        }
        let cwd = apply_worktree(record, spec)?;
        append_log_event(
            &record.log_path,
            serde_json::json!({
                "type": "lane_started",
                "lane_id": record.id,
                "runtime": "inline",
                "command": spec.command,
            }),
        )?;
        if !registry.mark_running_if_pending(record)? {
            bail!(
                "lane `{}` was stopped before inline start completed",
                record.id
            );
        }

        let mut cmd = Command::new(&spec.command[0]);
        if spec.command.len() > 1 {
            cmd.args(&spec.command[1..]);
        }
        if let Some(cwd) = cwd.as_ref() {
            cmd.current_dir(cwd);
        }
        cmd.envs(spec.environment.iter().map(|(key, value)| (key, value)));
        cmd.stdout(Stdio::piped()).stderr(Stdio::piped());
        let mut child = match cmd.spawn() {
            Ok(child) => child,
            Err(err) => {
                append_log_event(

View on GitHub (pinned to 73e0f67d83)