emilk/egui · error
Multiple SnapshotResults were dropped without being handled
Error message
Multiple SnapshotResults were dropped without being handled.
In order to allow consistent snapshot updates, all snapshot results within a test should be merged in a single SnapshotResults instance.
Usually 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`.
The SnapshotResult was constructed at {}
What it means
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.
Source
Thrown at crates/egui_kittest/src/snapshot.rs:983
#[expect(clippy::manual_assert)]
if self.has_errors() {
panic!("{}", self);
}
thread_local! {
static UNHANDLED_SNAPSHOT_RESULTS_COUNTER: core::cell::RefCell<usize> = const { core::cell::RefCell::new(0) };
}
if !self.handled {
let count = UNHANDLED_SNAPSHOT_RESULTS_COUNTER.with(|counter| {
let mut count = counter.borrow_mut();
*count += 1;
*count
});
#[expect(clippy::manual_assert)]
if count >= 2 {
panic!(
"
Multiple SnapshotResults were dropped without being handled.
In order to allow consistent snapshot updates, all snapshot results within a test should be merged in a single SnapshotResults instance.
Usually 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`.
The SnapshotResult was constructed at {}
",
self.location
);
}
}
}
}
View on GitHub (pinned to 441971a776)
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.
Example fix
// before: two harnesses, results dropped independently
let mut h1 = Harness::new(...); h1.image_snapshot("a");
let mut h2 = Harness::new(...); h2.image_snapshot("b");
// after: merge into a single SnapshotResults
let mut results = h1.take_snapshot_results();
results.extend(h2.take_snapshot_results());
results.assert_result(); Defensive patterns
Strategy: validation
Validate before calling
// ensure a single merged SnapshotResults per test let mut all = harness1.take_snapshot_results(); all.extend(harness2.take_snapshot_results()); assert_eq!(dropped_unhandled_results_expected(), 0); all.assert_result();
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- {}
- {err}
- Harness::ui_id is only available for harnesses built with a
- Unsupported value for UPDATE_SNAPSHOTS: {unknown:?}
- {err}
AI-assisted analysis of emilk/egui@441971a776 (2026-09-12).
Data as JSON: /api/errors/a3996f9ecb589a55.
Report an issue: GitHub.