{"record":{"id":"ddcc99d67e37371f","repo":"denoland/deno","slug":"panic-formatting","errorCode":null,"errorMessage":"Panic formatting: {}","messagePattern":"Panic formatting: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/fmt.rs","lineNumber":1711,"sourceCode":"    let f = f.clone();\n    let file_path = file_path.clone();\n    spawn_blocking(move || f(file_path))\n  });\n  let join_results = futures::future::join_all(handles).await;\n\n  // find the tasks that panicked and let the user know which files\n  let panic_file_paths = join_results\n    .iter()\n    .enumerate()\n    .filter_map(|(i, join_result)| {\n      join_result\n        .as_ref()\n        .err()\n        .map(|_| file_paths[i].to_string_lossy())\n    })\n    .collect::<Vec<_>>();\n  if !panic_file_paths.is_empty() {\n    panic!(\"Panic formatting: {}\", panic_file_paths.join(\", \"))\n  }\n\n  // check for any errors and if so return the first one\n  let mut errors = join_results.into_iter().filter_map(|join_result| {\n    join_result\n      .ok()\n      .and_then(|handle_result| handle_result.err())\n  });\n\n  match errors.next() {\n    Some(e) => Err(e),\n    _ => Ok(()),\n  }\n}\n\n/// This function is similar to is_supported_ext but adds additional extensions\n/// supported by `deno fmt`.\nfn is_supported_ext_fmt(path: &Path) -> bool {","sourceCodeStart":1693,"sourceCodeEnd":1729,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/fmt.rs#L1693-L1729","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reproduce on the named file alone (`deno fmt path/to/file.ts`) to confirm the trigger and minimize it","Update Deno to the latest patch release — formatter panics are usually fixed quickly","Exclude the offending file or folder via `\"fmt\": { \"exclude\": [...] }` in deno.json","If it reproduces on the latest version, open an issue at github.com/denoland/deno with the minimized file"],"exampleFix":"# before\n$ deno fmt .\nPanic formatting: src/gen/api.ts, src/gen/codec.ts\n\n# after — deno.json\n{\n  \"fmt\": { \"exclude\": [\"src/gen/\"] }\n}","handlingStrategy":"fallback","validationCode":"# isolate crashers before a project-wide fmt\ngit ls-files '*.ts' '*.js' '*.json' | while read -r f; do\n  deno fmt \"$f\" >/dev/null 2>&1 || echo \"fmt failed/crashed: $f\"\ndone","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Exclude generated/vendored directories with fmt.exclude in deno.json","Run per-file fmt in CI so one crashing file cannot hide the rest of the results","Keep Deno updated — formatter panics are usually fixed in patch releases","Reproduce any crash with `deno fmt <file>` and minimize before reporting"],"tags":["deno-fmt","formatting","panic","dprint","cli"],"backgroundTag":"formatter-crash","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}