oxc-project/oxc · error · OxcDiagnostic
Timeout must be a number.
Error message
Timeout must be a number.
What it means
Emitted by the vitest/require-test-timeout rule when the timeout value supplied to a test is not a number (e.g. a string or other expression). Vitest requires the timeout to be a numeric millisecond value, so a non-numeric timeout is invalid and flagged during timeout-value parsing.
Source
Thrown at crates/oxc_linter/src/rules/vitest/require_test_timeout.rs:40
"Add a numeric third argument, a `{ timeout }` option object second argument, or call `vi.setConfig({ testTimeout: ... })` before this test.",
)
.with_label(span)
}
fn config_missing_timeout_object(span: Span) -> OxcDiagnostic {
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: ... })`.View on GitHub (pinned to e1e7af627c)
Solutions
- Use a numeric literal for the timeout, e.g. `5000` instead of `'5000'`
- Cast or convert the value to a number before passing it
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/vitest/require_test_timeout.rs:40 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/2a4b06a16bc02dd4.
Report an issue: GitHub.