Skip to content

Remove unreachable return statement in timeout_with_retries function #76

@coderabbitai

Description

@coderabbitai

Problem

The timeout_with_retries function in crates/comenqd/src/daemon.rs contains unreachable code. The final return statement after the loop is never executed because all match arms within the loop already return.

Location

Issue

The function ends with:

    }

    Err(format!("{} exhausted all retry attempts", operation_name))
}

This final Err(...) statement is unreachable because:

  1. The loop iterates exactly 3 times (based on PROGRESSIVE_RETRY_PERCENTS = [50, 100, 150])
  2. On the final iteration, the timeout case always returns:
    Err(_) => {
        if attempt_num < timeouts.len() { // false on final attempt
            // retry logic
        } else {
            // This branch ALWAYS executes on the final attempt
            return Err(format!("{} timed out after all retry attempts", operation_name));
        }
    }

Solution

Remove the final two lines so the function ends immediately after the loop:

        }
    }
}

Context

Metadata

Metadata

Assignees

Labels

lowAin't annoying anyone but the QA department

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions