denoland/deno · error
Formatting not stable. Bailed after {} tries. This indicates
Error message
Formatting not stable. Bailed after {} tries. This indicates a bug in the formatter where it formats the file differently each time. As a temporary workaround you can ignore this file. What it means
`deno fmt` verifies idempotency: it re-formats its own output up to 5 times and expects identical text. This error means each pass produced different text (a formatting cycle), so the formatter is non-idempotent for this file — a bug in the formatter, not in your code.
Source
Thrown at cli/tools/fmt.rs:1227
}
Ok(None) => {
return Ok(Some(current_text));
}
Err(err) => {
bail!(
concat!(
"Formatting succeeded initially, but failed when ensuring a ",
"stable format. This indicates a bug in the formatter where ",
"the text it produces is not syntactically correct. As a temporary ",
"workaround you can ignore this file.\n\n{:#}"
),
err,
)
}
}
count += 1;
if count == 5 {
bail!(
concat!(
"Formatting not stable. Bailed after {} tries. This indicates a bug ",
"in the formatter where it formats the file differently each time. As a ",
"temporary workaround you can ignore this file."
),
count,
)
}
}
}
None => Ok(None),
}
}
/// Format stdin and write result to stdout.
/// Treats input as set by `--ext` flag.
/// Compatible with `--check` flag.
fn format_stdin(View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Exclude the file: `// deno-fmt-ignore-file` at the top, or "fmt": { "exclude": [...] } in deno.json
- Try a different Deno version — check the changelog for formatter fixes and upgrade
- Reduce to a minimal reproduction and file it at github.com/denoland/deno/issues so the cycle gets fixed
Example fix
# before: `deno fmt src/big_file.ts` -> Formatting not stable. Bailed after 5 tries. # after: first line of src/big_file.ts // deno-fmt-ignore-file
Defensive patterns
Strategy: fallback
Try / catch
Catch the non-zero exit of `deno fmt <file>`; if stderr contains 'Formatting not stable', mark the file with `// deno-fmt-ignore-file` (or add to deno.json fmt.exclude) and re-run the batch, recording which files were skipped for follow-up.
Prevention
- Test formatting in CI with `deno fmt --check` on the pinned Deno version
- Upgrade Deno deliberately and re-run fmt across the repo once, in a dedicated commit
- Report instability reproductions upstream — the workaround (ignore) is meant to be temporary
When it happens
Trigger: The loop in cli/tools/fmt.rs keeps getting next_pass_text != current_text; after the 5th pass (count == 5) it bails. Triggered by source constructs where two formatting rules keep flip-flopping (e.g. line-wrapping decisions in long expressions, comment alignment in markdown or CSS-in-template-literals).
Common situations: Formatter regressions after a Deno version bump; files with very long lines, dense destructuring, or markdown tables that alternate between two layouts; CI failing with 'not stable' on a file humans never touched.
Related errors
- Formatting succeeded initially, but failed when ensuring a s
- Missing bench function
- Unexpected 'fn' field in options, bench function is already
- Did not format non-workspace directory. Run again specifying
- Failed to read from stdin
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/58f55755ccf25cf4.
Report an issue: GitHub.