{"record":{"id":"2a3c0bd69cbc2124","repo":"Hmbown/CodeWhale","slug":"write-one-input-burst","errorCode":null,"errorMessage":"write one input burst","messagePattern":"write one input burst","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/palette/src/osc11_tests.rs","lineNumber":48,"sourceCode":"            response: b\"\\x1b_Gi=31;OK\\x1b\\\\\",\n            reply: b\"\\x1b_Gi=31;OK\",\n            csi: false,\n        },\n        Case {\n            query: b\"\\x1b[c\",\n            response: b\"\\x1b[?62;4c\",\n            reply: b\"\\x1b[?62;4c\",\n            csi: true,\n        },\n    ];\n\n    for case in cases {\n        let (mut reader, mut writer) = std::io::pipe().expect(\"create isolated input pipe\");\n        let prefix = b\"/plu\";\n        let suffix = b\"gin list\\r\";\n        let burst = [prefix.as_slice(), case.response, suffix.as_slice()].concat();\n        assert_eq!(\n            writer.write(&burst).expect(\"write one input burst\"),\n            burst.len()\n        );\n\n        // Keep the writer open: a buffered read-ahead must not be rescued by\n        // EOF/readable-HUP while the real tty would have no new bytes ready.\n        let (answered, reply, carried) = read_terminal_reply(\n            reader.as_raw_fd(),\n            case.query,\n            Duration::from_secs(1),\n            case.csi,\n        );\n        drop(writer);\n        let mut remaining = Vec::new();\n        reader\n            .read_to_end(&mut remaining)\n            .expect(\"read remaining typed input\");\n\n        assert!(","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/palette/src/osc11_tests.rs#L30-L66","documentation":"The test writes a single concatenated burst (typed prefix + terminal reply + typed suffix) to the pipe with `writer.write(&burst).expect(\"write one input burst\")`, asserting the write consumed every byte. The panic fires if the write fails (broken pipe, EINTR surfaced as error, writer closed) or, via the `assert_eq!`, if it was a short write.","triggerScenarios":"Reader end closed before the write completes (broken pipe/EPIPE); a partial write returning fewer bytes than `burst.len()` (large bursts over a full pipe buffer — unlikely at this size); the writer dropped mid-iteration.","commonSituations":"Reordering test code so the reader is dropped first; pipe buffer capacity exceeded when the burst is enlarged; platform quirks surfacing EINTR as an error.","solutions":["Ensure the reader end stays open until after the write","Use `write_all` to eliminate short-write failures on the assert","Check burst size against the pipe buffer capacity (64 KiB on Linux) if the payload grows","Retry on `ErrorKind::Interrupted`"],"exampleFix":"// before\nassert_eq!(writer.write(&burst).expect(\"write one input burst\"), burst.len());\n// after\nwriter.write_all(&burst).expect(\"write one input burst\");","handlingStrategy":"try-catch","validationCode":"// Keep the reader open before writing\nlet _reader_keepalive = reader.try_clone().expect(\"reader clone\");","typeGuard":null,"tryCatchPattern":"writer.write_all(&burst)\n    .unwrap_or_else(|e| panic!(\"burst write failed: {e}\")); // write_all also kills short writes","preventionTips":["Always use write_all for atomic test fixtures","Keep the reader end alive until writes finish","Retry once on ErrorKind::Interrupted"],"tags":["rust","io","pipe","write"],"backgroundTag":"broken-pipe","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}