oxc-project/oxc · error · OxcDiagnostic

Timeout must not be negative.

Error message

Timeout must not be negative.

What it means

Fires in the vitest require-test-timeout rule when parse_timeout_value encounters a negative numeric timeout literal. It is a validation guard rejecting any timeout value below zero, which vitest treats as invalid because a test cannot wait for a negative duration.

Source

Thrown at crates/oxc_linter/src/rules/vitest/require_test_timeout.rs:46

    OxcDiagnostic::warn("`vi.setConfig()` is missing a `testTimeout` property.")
        .with_help("Pass an object with a `testTimeout` property to `vi.setConfig()`.")
        .with_label(span)
}

fn test_options_missing_timeout_property(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Test options object is missing a `timeout` property.")
        .with_help("Add a `timeout` property to the options object.")
        .with_label(span)
}

fn timeout_must_be_a_number(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Timeout must be a number.")
        .with_help("Use a non-negative numeric literal for the timeout value.")
        .with_label(span)
}

fn timeout_must_be_non_negative(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Timeout must not be negative.")
        .with_help("Use a non-negative numeric literal for the timeout value.")
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct RequireTestTimeout;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Requires every test to have a timeout specified, either as a numeric third
    /// argument, a `{ timeout }` option, or via `vi.setConfig({ testTimeout: ... })`.
    ///
    /// ### Why is this bad?
    ///
    /// Tests without an explicit timeout rely on the default, which may be too
    /// generous to catch performance regressions or too short for slow CI
    /// environments, leading to flaky failures.

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Set the timeout to a non-negative number of milliseconds
  2. Remove the timeout option to use the configured default test timeout
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/vitest/require_test_timeout.rs:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/66a74d8ee774d4fb. Report an issue: GitHub.