{"record":{"id":"a3996f9ecb589a55","repo":"emilk/egui","slug":"multiple-snapshotresults-were-dropped-without-bei","errorCode":null,"errorMessage":"\nMultiple SnapshotResults were dropped without being handled.\n\nIn order to allow consistent snapshot updates, all snapshot results within a test should be merged in a single SnapshotResults instance.\nUsually this is handled internally in a harness. If you have multiple harnesses, you can merge the results using `Harness::take_snapshot_results` and `SnapshotResults::extend`.\n\nThe SnapshotResult was constructed at {}\n                    ","messagePattern":"\nMultiple SnapshotResults were dropped without being handled\\.\n\nIn order to allow consistent snapshot updates, all snapshot results within a test should be merged in a single SnapshotResults instance\\.\nUsually this is handled internally in a harness\\. If you have multiple harnesses, you can merge the results using `Harness::take_snapshot_results` and `SnapshotResults::extend`\\.\n\nThe SnapshotResult was constructed at (.+?)\n                    ","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/egui_kittest/src/snapshot.rs","lineNumber":983,"sourceCode":"        #[expect(clippy::manual_assert)]\n        if self.has_errors() {\n            panic!(\"{}\", self);\n        }\n\n        thread_local! {\n            static UNHANDLED_SNAPSHOT_RESULTS_COUNTER: core::cell::RefCell<usize> = const { core::cell::RefCell::new(0) };\n        }\n\n        if !self.handled {\n            let count = UNHANDLED_SNAPSHOT_RESULTS_COUNTER.with(|counter| {\n                let mut count = counter.borrow_mut();\n                *count += 1;\n                *count\n            });\n\n            #[expect(clippy::manual_assert)]\n            if count >= 2 {\n                panic!(\n                    \"\nMultiple SnapshotResults were dropped without being handled.\n\nIn order to allow consistent snapshot updates, all snapshot results within a test should be merged in a single SnapshotResults instance.\nUsually this is handled internally in a harness. If you have multiple harnesses, you can merge the results using `Harness::take_snapshot_results` and `SnapshotResults::extend`.\n\nThe SnapshotResult was constructed at {}\n                    \",\n                    self.location\n                );\n            }\n        }\n    }\n}\n","sourceCodeStart":965,"sourceCodeEnd":998,"githubUrl":"https://github.com/emilk/egui/blob/441971a776322a482e371775219380eca812cfa9/crates/egui_kittest/src/snapshot.rs#L965-L998","documentation":"When a SnapshotResults is dropped unhandled, a thread-local counter tracks how many such drops occurred; if two or more happen in one test, this panic fires. It exists because multiple separate SnapshotResults instances break consistent snapshot updating (e.g. one instance may trigger an update while another still reports a mismatch). The message tells you to merge all results into a single SnapshotResults per test.","triggerScenarios":"Dropping two or more SnapshotResults without handling them in the same test thread — typically created by multiple Harnesses (or standalone snapshot calls) in one #[test] whose results are never taken/merged.","commonSituations":"A test with two or more harnesses each doing image_snapshot but never merging results; refactoring a test to spawn several harnesses without updating the result-collection logic; helper functions that each create their own harness.","solutions":["Collect each harness's results with Harness::take_snapshot_results and merge them all into one SnapshotResults with SnapshotResults::extend before the test ends.","Call assert_result (or equivalent) on the merged SnapshotResults so nothing is dropped unhandled.","Restructure the test to use a single harness when possible, avoiding multiple independent SnapshotResults."],"exampleFix":"// before: two harnesses, results dropped independently\nlet mut h1 = Harness::new(...); h1.image_snapshot(\"a\");\nlet mut h2 = Harness::new(...); h2.image_snapshot(\"b\");\n\n// after: merge into a single SnapshotResults\nlet mut results = h1.take_snapshot_results();\nresults.extend(h2.take_snapshot_results());\nresults.assert_result();","handlingStrategy":"validation","validationCode":"// ensure a single merged SnapshotResults per test\nlet mut all = harness1.take_snapshot_results();\nall.extend(harness2.take_snapshot_results());\nassert_eq!(dropped_unhandled_results_expected(), 0);\nall.assert_result();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use exactly one Harness (and thus one SnapshotResults) per test whenever possible.","When multiple harnesses are unavoidable, merge with Harness::take_snapshot_results + SnapshotResults::extend immediately after each finishes.","Assert on the merged results before the test ends so nothing is dropped unhandled.","Extract a helper that returns merged SnapshotResults so ad-hoc harnesses in helpers don't leak results."],"tags":["snapshot-testing","panic","rust","testing"],"backgroundTag":"invalid-state-transition","analyzedSha":"441971a776322a482e371775219380eca812cfa9","analyzedAt":"2026-09-12T04:29:21.500Z","contentChangedAt":"2026-09-12T04:29:21.500Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}