{"record":{"id":"ee30d8695114da07","repo":"denoland/deno","slug":"formatting-succeeded-initially-but-failed-when-en","errorCode":null,"errorMessage":"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{:#}","messagePattern":"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(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/fmt.rs","lineNumber":1214,"sourceCode":"        match fmt_func(\n          file_path,\n          &FileContents {\n            had_bom: false,\n            text: (&current_text).into(),\n          },\n        ) {\n          Ok(Some(next_pass_text)) => {\n            // just in case\n            if next_pass_text == current_text {\n              return Ok(Some(next_pass_text));\n            }\n            current_text = next_pass_text;\n          }\n          Ok(None) => {\n            return Ok(Some(current_text));\n          }\n          Err(err) => {\n            bail!(\n              concat!(\n                \"Formatting succeeded initially, but failed when ensuring a \",\n                \"stable format. This indicates a bug in the formatter where \",\n                \"the text it produces is not syntactically correct. As a temporary \",\n                \"workaround you can ignore this file.\\n\\n{:#}\"\n              ),\n              err,\n            )\n          }\n        }\n        count += 1;\n        if count == 5 {\n          bail!(\n            concat!(\n              \"Formatting not stable. Bailed after {} tries. This indicates a bug \",\n              \"in the formatter where it formats the file differently each time. As a \",\n              \"temporary workaround you can ignore this file.\"\n            ),","sourceCodeStart":1196,"sourceCodeEnd":1232,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/fmt.rs#L1196-L1232","documentation":"After formatting a file, `deno fmt` re-parses and re-formats its own output to verify stability. This error means the first formatting pass succeeded but the produced text failed to parse on the verification pass — the formatter emitted syntactically invalid output. This is a bug in the formatter (dprint plugin) for that input, not a problem with your file.","triggerScenarios":"Formatting a file whose syntax hits a formatter bug: exotic TypeScript/JavaScript constructs, markdown files with unusual embedded code blocks, or edge cases in a specific Deno version's dprint plugin. The verification loop at cli/tools/fmt.rs:1214 calls format_file again on the formatted text and the second parse returns Err.","commonSituations":"Appearing right after a Deno upgrade that introduced a formatter regression; files mixing languages (markdown with code fences, inline expressions in template literals); CI formatting jobs suddenly failing on files that used to format fine.","solutions":["Temporarily exclude the offending file: add `// deno-fmt-ignore-file` as the first line, or add it to \"exclude\" under \"fmt\" in deno.json","Upgrade (or downgrade) Deno — such regressions are usually fixed quickly in a patch release","Minimize the file to the smallest snippet that reproduces it and report it at github.com/denoland/deno/issues"],"exampleFix":"// before — deno.json\n{}\n\n// after — skip the file that trips the formatter bug\n{\n  \"fmt\": {\n    \"exclude\": [\"src/tricky_file.ts\"]\n  }\n}\n\n// or inline, first line of the file:\n// deno-fmt-ignore-file","handlingStrategy":"fallback","validationCode":"# smoke-test formattability of the exact file set before CI commits to fmt:\ndeno fmt --check . || deno fmt .\n# per-file loop lets one bad file be excluded instead of failing the job:\nfor f in $(git ls-files '*.ts'); do deno fmt \"$f\" || echo \"fmt-bug: $f\" >> fmt-skip.txt; done","typeGuard":null,"tryCatchPattern":"When invoking deno fmt programmatically (Node/Bun): spawn it, on non-zero exit scan stderr for 'Formatting succeeded initially, but failed when ensuring a stable format'; if found, add the named file to fmt exclude and re-run instead of failing the build.","preventionTips":["Run `deno fmt --check` in CI so formatter bugs surface before commit hooks","Pin the Deno version (dvm/asdf/.tool-versions) so a formatter regression can't arrive unannounced","Keep a short fmt exclude list ready; treat additions as temporary until the Deno fix lands"],"tags":["fmt","formatter","parser","idempotency","bug"],"backgroundTag":"formatter-unstable-output","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}