denoland/deno · error

Panic formatting: {}

Error message

Panic formatting: {}

What it means

`deno fmt` formats files on parallel worker threads; when a worker panics mid-format, the CLI collects every file whose task died and re-panics with their names so the crash is attributable. It almost always means the embedded formatter (dprint) hit a bug or an input it cannot process. The whole run aborts; this is not related to formatting style errors in your code.

Source

Thrown at cli/tools/fmt.rs:1711

    let f = f.clone();
    let file_path = file_path.clone();
    spawn_blocking(move || f(file_path))
  });
  let join_results = futures::future::join_all(handles).await;

  // find the tasks that panicked and let the user know which files
  let panic_file_paths = join_results
    .iter()
    .enumerate()
    .filter_map(|(i, join_result)| {
      join_result
        .as_ref()
        .err()
        .map(|_| file_paths[i].to_string_lossy())
    })
    .collect::<Vec<_>>();
  if !panic_file_paths.is_empty() {
    panic!("Panic formatting: {}", panic_file_paths.join(", "))
  }

  // check for any errors and if so return the first one
  let mut errors = join_results.into_iter().filter_map(|join_result| {
    join_result
      .ok()
      .and_then(|handle_result| handle_result.err())
  });

  match errors.next() {
    Some(e) => Err(e),
    _ => Ok(()),
  }
}

/// This function is similar to is_supported_ext but adds additional extensions
/// supported by `deno fmt`.
fn is_supported_ext_fmt(path: &Path) -> bool {

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Reproduce on the named file alone (`deno fmt path/to/file.ts`) to confirm the trigger and minimize it
  2. Update Deno to the latest patch release — formatter panics are usually fixed quickly
  3. Exclude the offending file or folder via `"fmt": { "exclude": [...] }` in deno.json
  4. If it reproduces on the latest version, open an issue at github.com/denoland/deno with the minimized file

Example fix

# before
$ deno fmt .
Panic formatting: src/gen/api.ts, src/gen/codec.ts

# after — deno.json
{
  "fmt": { "exclude": ["src/gen/"] }
}
Defensive patterns

Strategy: fallback

Validate before calling

# isolate crashers before a project-wide fmt
git ls-files '*.ts' '*.js' '*.json' | while read -r f; do
  deno fmt "$f" >/dev/null 2>&1 || echo "fmt failed/crashed: $f"
done

Try / catch

deno fmt . || { echo 'fmt crashed; falling back to per-file'; for f in $(git ls-files '*.ts'); do deno fmt "$f" || echo "bad: $f"; done; }

Prevention

When it happens

Trigger: Running `deno fmt` (project-wide or on a directory) where at least one file makes the TypeScript/JSON/CSS/markup formatter panic — exotic syntax, a corrupted or generated file, or a formatter regression in that Deno version. The listed paths are exactly the files whose join handles came back as panics.

Common situations: Formatting highly generated or minified files; vendored node_modules content pulled into fmt scope; a Deno up/downgrade changing formatter behavior; genuine dprint plugin bugs fixed in later patch releases.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/ddcc99d67e37371f. Report an issue: GitHub.