{"record":{"id":"ea830f84122dc65c","repo":"rust-lang/rust-analyzer","slug":"unable-to-write-data","errorCode":null,"errorMessage":"Unable to write data","messagePattern":"Unable to write data","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rust-analyzer/src/tracing/json.rs","lineNumber":72,"sourceCode":"\n    fn on_event(&self, _event: &Event<'_>, _ctx: Context<'_, S>) {}\n\n    fn on_close(&self, id: Id, ctx: Context<'_, S>) {\n        #[derive(serde_derive::Serialize)]\n        struct JsonDataInner {\n            name: &'static str,\n            elapsed_ms: u128,\n        }\n\n        let span = ctx.span(&id).unwrap();\n        let Some(data) = span.extensions_mut().remove::<JsonData>() else {\n            return;\n        };\n\n        let data = JsonDataInner { name: data.name, elapsed_ms: data.start.elapsed().as_millis() };\n        let mut out = serde_json::to_string(&data).expect(\"Unable to serialize data\");\n        out.push('\\n');\n        self.writer.make_writer().write_all(out.as_bytes()).expect(\"Unable to write data\");\n    }\n}\n\n#[derive(Default, Clone, Debug)]\npub(crate) struct JsonFilter {\n    pub(crate) allowed_names: Option<FxHashSet<String>>,\n}\n\nimpl JsonFilter {\n    pub(crate) fn from_spec(spec: &str) -> Self {\n        let allowed_names = if spec == \"*\" {\n            None\n        } else {\n            Some(FxHashSet::from_iter(spec.split('|').map(String::from)))\n        };\n\n        Self { allowed_names }\n    }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/crates/rust-analyzer/src/tracing/json.rs#L54-L90","documentation":"After serializing the span record, the JSON profiling layer writes it to the configured writer and expects the write to succeed. A panic here means the underlying MakeWriter failed to write all bytes (I/O error), e.g. the profiling output file or pipe disappeared or is unwritable.","triggerScenarios":"A span closes while the profiler is active and the writer's target (file, stderr, socket) returns an error or partial write: disk full, file handle closed, broken pipe when output is piped to a process that exited.","commonSituations":"Running rust-analyzer with profiling output redirected to a file on a full disk; profiling output piped to `head` or another short-lived consumer that closes the pipe; permissions changed on the output file mid-session.","solutions":["Ensure the profiling output destination is writable and has free space (check disk quota, df).","Avoid piping profiling output to short-lived consumers; redirect to a file instead.","Check the writer configuration (env/config for profiling output) points to a valid, accessible path.","If scripting around rust-analyzer, keep the consuming process alive for the session."],"exampleFix":"// before\nrust-analyzer --profile-... | head -n 5   # pipe closes early -> panic\n// after\nrust-analyzer ... > /tmp/ra-profile.jsonl  # stable file target","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = self.writer.make_writer().write_all(out.as_bytes()) {\n    eprintln!(\"profile write failed: {e}\"); // degrade instead of panicking\n}","preventionTips":["Write profiling output to a local file, never a short-lived pipe","Ensure adequate disk space and write permissions on the output path","Keep any consuming process alive for the whole session"],"tags":["rust-analyzer","tracing","io","panic"],"backgroundTag":"broken-pipe-write-failure","analyzedSha":"e8f7e90aa3e7b26aa9a000200f606c1078da99ec","analyzedAt":"2026-09-03T21:08:06.959Z","contentChangedAt":"2026-09-03T21:08:06.959Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}