{"record":{"id":"8119932b76a654ca","repo":"biomejs/biome","slug":"tried-to-format-a-format-once-at-least-twice-th","errorCode":null,"errorMessage":"Tried to format a `format_once` at least twice. This is not allowed. You may want to use `format_with` or `format.memoized` instead.","messagePattern":"Tried to format a `format_once` at least twice\\. This is not allowed\\. You may want to use `format_with` or `format\\.memoized` instead\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/biome_formatter/src/builders.rs","lineNumber":2680,"sourceCode":"{\n    FormatOnce {\n        formatter: Cell::new(Some(formatter)),\n        context: PhantomData,\n    }\n}\n\npub struct FormatOnce<T, Context> {\n    formatter: Cell<Option<T>>,\n    context: PhantomData<Context>,\n}\n\nimpl<T, Context> Format<Context> for FormatOnce<T, Context>\nwhere\n    T: FnOnce(&mut Formatter<Context>) -> FormatResult<()>,\n{\n    #[inline(always)]\n    fn fmt(&self, f: &mut Formatter<Context>) -> FormatResult<()> {\n        let formatter = self.formatter.take().expect(\"Tried to format a `format_once` at least twice. This is not allowed. You may want to use `format_with` or `format.memoized` instead.\");\n\n        (formatter)(f)\n    }\n}\n\nimpl<T, Context> std::fmt::Debug for FormatOnce<T, Context> {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        f.debug_tuple(\"FormatOnce\").field(&\"{{formatter}}\").finish()\n    }\n}\n\n/// Builder to join together a sequence of content.\n/// See [Formatter::join]\n#[must_use = \"must eventually call `finish()` on Format builders\"]\npub struct JoinBuilder<'fmt, 'buf, Separator, Context> {\n    result: FormatResult<()>,\n    fmt: &'fmt mut Formatter<'buf, Context>,\n    with: Option<Separator>,","sourceCodeStart":2662,"sourceCodeEnd":2698,"githubUrl":"https://github.com/biomejs/biome/blob/405dedb0ff65dd29927faf587f6542e3c29db248/crates/biome_formatter/src/builders.rs#L2662-L2698","documentation":"Error \"Tried to format a `format_once` at least twice. This is not allowed. You may want to use `format_with` or `format.memoized` instead.\" thrown in biomejs/biome.","triggerScenarios":"Thrown at crates/biome_formatter/src/builders.rs:2680 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use `format_with` or `format.memoized` for values that must be formatted more than once.","Refactor the format call chain so each `format_once` node is emitted exactly once."],"exampleFix":"let memo = content.memoized(); format_with(|f| { write!(f, [memo, memo]) })","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"405dedb0ff65dd29927faf587f6542e3c29db248","analyzedAt":"2026-08-20T00:25:09.682Z","contentChangedAt":"2026-08-20T00:25:09.682Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}