{"record":{"id":"0a75735e69ab4eb7","repo":"slint-ui/slint","slug":"file-not-found","errorCode":null,"errorMessage":"File not found","messagePattern":"File not found","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"internal/live-preview/preview_sessions.rs","lineNumber":178,"sourceCode":"        debounce_deadline: &mut Option<tokio::time::Instant>,\n    ) -> bool {\n        match message {\n            LspToPreviewMessage::InvalidateContents { url } => {\n                if !is_supported(&url) {\n                    return true;\n                }\n                self.file_cache.borrow_mut().remove(&url);\n                self.schedule_rebuild(&url, debounce_deadline);\n            }\n            LspToPreviewMessage::ForgetFile { url } => {\n                if !is_supported(&url) {\n                    return true;\n                }\n                if let Some(CacheEntry::Loading(senders)) =\n                    self.file_cache.borrow_mut().remove(&url)\n                {\n                    for sender in senders {\n                        let _ = sender.send(Err(std::io::Error::new(\n                            std::io::ErrorKind::NotFound,\n                            \"File not found\",\n                        )));\n                    }\n                }\n                self.schedule_rebuild(&url, debounce_deadline);\n            }\n            LspToPreviewMessage::SetContents { url, contents } => {\n                if !is_supported(url.url()) {\n                    return true;\n                }\n                if i_slint_compiler::pathutils::is_font_file(url.url().path()) {\n                    event_handler(PreviewSessionEvent::RegisterFont {\n                        url: url.url().clone(),\n                        contents: contents.into(),\n                    });\n                    return true;\n                }","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/live-preview/preview_sessions.rs#L160-L196","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet content = load_file(url).await?; // panics/aborts on NotFound\n// after\nmatch load_file(url).await {\n    Ok(c) => compile(c),\n    Err(e) if e.kind() == std::io::ErrorKind::NotFound => log::warn!(\"{url} deleted; skipping\"),\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"try-catch","validationCode":"// before requesting, confirm the file exists\nif !std::path::Path::new(&file_path).exists() { skip_load(); }","typeGuard":null,"tryCatchPattern":"match load_file(url).await {\n    Ok(c) => compile(c),\n    Err(e) if e.kind() == ErrorKind::NotFound => /* file deleted; skip */,\n    Err(e) => return Err(e.into()),\n}","preventionTips":["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."],"tags":["live-preview","file-system","race-condition","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}