Hmbown/CodeWhale · warning

heavy command canceled while queued for resource admission

Error message

heavy command canceled while queued for resource admission

What it means

A heavy command (e.g. cargo build) waiting in the resource-admission queue was canceled via its CancellationToken before a slot became available. The queue loop checks the token each iteration and aborts with this error instead of acquiring a permit.

Solutions

  1. Expected on cancellation — treat as benign abort and do not retry automatically
  2. Re-run the command when host load drops so admission slots free up
  3. If it fires without user action, check for runaway tasks holding permits (leaked permit without release)
  4. Verify cancellation tokens are only canceled on real user/shutdown requests
Defensive patterns

Strategy: try-catch

Validate before calling

// Before launching, check the token so you rarely queue into a cancel
if token.is_cancelled() { return; }

Try / catch

match acquire_heavy_command_permit(&token).await { Err(e) if e.to_string().contains("canceled while queued") => info!("user canceled queued command"), ... }

Prevention

When it happens

Trigger: The user pressed Esc / canceled the tool call while the command sat queued because all heavy-command slots were busy; memory-pressure limiting reduced admission slots to zero so the queue drained slowly; the engine canceled the task on shutdown or timeout.

Common situations: Running many parallel cargo commands on a saturated host; #4864-style critical memory pressure where effective slots drop to 0; user aborts a long-waiting tool call.

Related errors


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

Appendix: source

Thrown at crates/tui/src/tools/resource_admission.rs:189

    acquire_heavy_command_permit_at(&root, limit, cancel, &probe)
        .await
        .map(Some)
}

async fn acquire_heavy_command_permit_at(
    root: &Path,
    limit: usize,
    cancel: Option<&CancellationToken>,
    probe: &dyn MemoryProbe,
) -> Result<HeavyCommandPermit> {
    tokio::fs::create_dir_all(root)
        .await
        .with_context(|| format!("creating resource admission directory {}", root.display()))?;
    let started = Instant::now();

    loop {
        if cancel.is_some_and(|token| token.is_cancelled()) {
            return Err(anyhow!(
                "heavy command canceled while queued for resource admission"
            ));
        }
        // Re-measure each iteration: under memory pressure the effective limit
        // tightens so a saturated host stops admitting new heavy link graphs
        // (#4864 req 7). Critical pressure yields zero slots, so the command
        // waits for recovery instead of snowballing.
        let pressure = classify_memory_pressure(probe.free_fraction());
        let effective = effective_admission_limit(limit, pressure);
        for slot in 0..effective {
            let path = root.join(format!("heavy-{slot}.lock"));
            match try_lock_slot(&path) {
                Ok(Some(slot)) => {
                    return Ok(HeavyCommandPermit {
                        _slot: slot,
                        queued_for: started.elapsed(),
                        limit,
                        memory_pressure: pressure,

View on GitHub (pinned to 73e0f67d83)