slint-ui/slint · error · std::io::Error
File not found
Error message
File not found
What it means
In the live-preview session's message processing, when a file's cache entry is in the Loading state and the file turns out to be gone (e.g. a delete event arrived), all pending load senders are resolved with a NotFound 'File not found' io::Error. Anyone awaiting that file's contents receives this error.
Solutions
- Recreate or restore the deleted file so the loader can resolve it.
- Handle the NotFound error in the code awaiting the file load and skip/cancel compilation of that file.
- Trigger a reload of the session's file list so the deleted path is no longer requested.
Example fix
// before
let content = load_file(url).await?; // panics/aborts on NotFound
// after
match load_file(url).await {
Ok(c) => compile(c),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => log::warn!("{url} deleted; skipping"),
Err(e) => return Err(e.into()),
} Defensive patterns
Strategy: try-catch
Validate before calling
// before requesting, confirm the file exists
if !std::path::Path::new(&file_path).exists() { skip_load(); } Try / catch
match load_file(url).await {
Ok(c) => compile(c),
Err(e) if e.kind() == ErrorKind::NotFound => /* file deleted; skip */,
Err(e) => return Err(e.into()),
} Prevention
- Handle file-deletion watcher events by cancelling pending loads for that URL.
- Never reuse cached Loading entries for paths that no longer exist on disk.
When it happens
Trigger: A file is deleted (or its URL no longer maps to an existing file) while the preview had registered load waiters under CacheEntry::Loading; process_message handles the removal and broadcasts the error to every waiting sender.
Common situations: Deleting or renaming a .slint file in the editor while preview is loading/compiling it; file watchers firing remove events mid-load; stale editor buffers referencing removed files.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Preview session is no longer available
- Cannot get property
- Cannot get property
- Cannot invoke callback
- Cannot invoke callback
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/0a75735e69ab4eb7.
Report an issue: GitHub.
Appendix: source
Thrown at internal/live-preview/preview_sessions.rs:178
debounce_deadline: &mut Option<tokio::time::Instant>,
) -> bool {
match message {
LspToPreviewMessage::InvalidateContents { url } => {
if !is_supported(&url) {
return true;
}
self.file_cache.borrow_mut().remove(&url);
self.schedule_rebuild(&url, debounce_deadline);
}
LspToPreviewMessage::ForgetFile { url } => {
if !is_supported(&url) {
return true;
}
if let Some(CacheEntry::Loading(senders)) =
self.file_cache.borrow_mut().remove(&url)
{
for sender in senders {
let _ = sender.send(Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"File not found",
)));
}
}
self.schedule_rebuild(&url, debounce_deadline);
}
LspToPreviewMessage::SetContents { url, contents } => {
if !is_supported(url.url()) {
return true;
}
if i_slint_compiler::pathutils::is_font_file(url.url().path()) {
event_handler(PreviewSessionEvent::RegisterFont {
url: url.url().clone(),
contents: contents.into(),
});
return true;
}View on GitHub (pinned to bb937076de)