denoland/deno · error

No bench modules found

Error message

No bench modules found

What it means

deno bench collected zero bench modules and the permit_no_files option is false (cli/tools/bench/mod.rs:490-492). Discovery per workspace member matches script-extension files whose basename ends with '_bench' or '.bench' or equals 'bench' (has_supported_bench_path_name, cli/tools/bench/mod.rs:451-460), or files matched by explicit bench.include patterns / paths passed on the command line.

Source

Thrown at cli/tools/bench/mod.rs:491

  let specifiers = members_with_bench_options
    .iter()
    .map(|(_, bench_options)| {
      collect_specifiers(
        CollectSpecifiersOptions {
          file_patterns: bench_options.files.clone(),
          vendor_folder: cli_options.vendor_dir_path().map(ToOwned::to_owned),
          include_ignored_specified: false,
        },
        is_supported_bench_path,
      )
    })
    .collect::<Result<Vec<_>, _>>()?
    .into_iter()
    .flatten()
    .collect::<Vec<_>>();

  if !workspace_bench_options.permit_no_files && specifiers.is_empty() {
    return Err(anyhow!("No bench modules found"));
  }

  let main_graph_container = factory.main_module_graph_container().await?;
  main_graph_container
    .check_specifiers(
      &specifiers,
      CheckSpecifiersOptions {
        ext_overwrite: cli_options.ext_flag().as_ref(),
        ..Default::default()
      },
    )
    .await?;

  if workspace_bench_options.no_run {
    return Ok(());
  }

  let preload_modules = cli_options.preload_modules()?;

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Name bench files to match the convention: *_bench.ts, *.bench.ts, or bench.ts (any script extension) in/below the workspace
  2. Or pass files explicitly: deno bench src/my_benches/insert.ts (explicit paths are always accepted)
  3. Or add globs in deno.json: "bench": { "include": ["src/**/*.bench.ts"] }
  4. If zero benches is expected (skeleton repo, generated project), pass --permit-no-files so the run succeeds

Example fix

// before (deno.json)
{
  "bench": { "include": ["benchmarks/**/*.ts"] }
}
// after - match the file naming actually used, or rename files to *_bench.ts
{
  "bench": { "include": ["src/**/*.bench.ts", "benchmarks/**/*.bench.ts"] }
}
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
# Verify discovery will find something before invoking deno bench
shopt -s globstar
files=( **/*_bench.ts **/*.bench.ts **/bench.ts )
[ ${#files[@]} -gt 0 ] || { echo 'no bench files match *_bench.ts / *.bench.ts / bench.ts'; exit 1; }
deno bench "$@"

Try / catch

# Skeleton repos/CI where zero benches is acceptable
deno bench --permit-no-files || { rc=$?; [ "$rc" -ne 0 ] && echo 'bench discovery empty - add benches or fix bench.include'; exit $rc; }

Prevention

When it happens

Trigger: Bench files exist but use another naming convention (e.g. benchmarks/bench_insert.ts vs the required *_bench.ts pattern) and no bench.include glob covers them; a fresh repo with no benches yet; all discovered matches excluded by bench.exclude; running deno bench in the wrong directory/workspace member.

Common situations: New project where benches haven't been written yet; a CI job that runs deno bench on a template/skeleton repo; teams naming files bench_insert.test.ts out of habit from other frameworks; bench.include misconfigured in deno.json.

Related errors


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/6adc0f0dfc0388df. Report an issue: GitHub.