epi052/feroxbuster · error

Could not get underlying CommandSender object

Error message

Could not get underlying CommandSender object

What it means

send_scan_command returns this error when the internal CommandSender handle cannot be retrieved. The container holds channel senders behind a read lock; if the guard fails or the slot is None (senders not initialized or already torn down), there is nothing to send the command through.

Solutions

  1. Ensure the handler container is fully initialized (initialize/senders populated) before calling send_scan_command
  2. Do not enqueue scan commands after initiating shutdown; join the event loop first
  3. In tests, build the container through the standard constructor so senders are registered
  4. Retry the call if it happens during shutdown rather than at startup

Example fix

// before
container.send_scan_command(Command::AddError)?; // during shutdown
// after
if !container.is_shutting_down() {
    container.send_scan_command(Command::AddError)?;
}
Defensive patterns

Strategy: try-catch

Validate before calling

fn send_if_ready(container: &Container, cmd: Command) -> anyhow::Result<()> {
    if container.is_shutting_down() {
        return Ok(()); // nothing to send to
    }
    container.send_scan_command(cmd)
}

Try / catch

match container.send_scan_command(cmd) {
    Ok(_) => {}
    Err(e) if e.to_string().contains("Could not get underlying CommandSender") => {
        log::warn!("scan senders unavailable (shutting down?); dropping command");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling send_scan_command after the event loop/senders have been dropped or before initialization, or when the RwLock read guard yields None; typically during shutdown or in tests where the handler container was never started.

Common situations: Sending scan commands during application shutdown races with teardown; unit tests constructing a partial container without initialize(); a prior panic poisoned the senders map.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of epi052/feroxbuster@1f595dab5c (2026-09-13). Data as JSON: /api/errors/02ed12d06eb42953. Report an issue: GitHub.

Appendix: source

Thrown at src/event_handlers/container.rs:129

    /// Set the ScanHandle object
    pub fn set_scan_handle(&self, handle: ScanHandle) {
        if let Ok(mut guard) = self.scans.write() {
            if guard.is_none() {
                guard.replace(handle);
            }
        }
    }

    /// Helper to easily send a Command over the (locked) underlying CommandSender object
    pub fn send_scan_command(&self, command: Command) -> Result<()> {
        if let Ok(guard) = self.scans.read().as_ref() {
            if let Some(handle) = guard.as_ref() {
                handle.send(command)?;
                return Ok(());
            }
        }

        bail!("Could not get underlying CommandSender object")
    }

    /// wrapper to reach into `FeroxScans` and yank out the length of `collected_extensions`
    pub fn num_collected_extensions(&self) -> usize {
        if !self.config.collect_extensions {
            // if --collect-extensions wasn't used, simply return 0 and forego unlocking
            return 0;
        }

        self.collected_extensions().len()
    }

    /// wrapper to reach into `FeroxScans` and yank out the length of `collected_extensions`
    pub fn collected_extensions(&self) -> HashSet<String> {
        if let Ok(scans) = self.ferox_scans() {
            if let Ok(extensions) = scans.collected_extensions.read() {
                return extensions.clone();
            }

View on GitHub (pinned to 1f595dab5c)