{"record":{"id":"a779f6b3dca1b9d4","repo":"slint-ui/slint","slug":"path-is-still-loading","errorCode":null,"errorMessage":"{path:?} is still loading","messagePattern":"(.+?) is still loading","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"internal/compiler/typeloader.rs","lineNumber":1018,"sourceCode":"        self.revision = self.revision.wrapping_add(1);\n    }\n\n    pub fn revision(&self) -> u64 {\n        self.revision\n    }\n\n    /// Drop a document from the TypeLoader and invalidate all of its dependencies.\n    /// Returns the list of all (transitive) dependencies.\n    ///\n    /// This forces the compiler to entirely reload the document from scratch.\n    /// To only cause a re-analyze, but not a reparse, use [Self::invalidate_document]\n    pub fn drop_document(&mut self, path: &Path) -> Result<HashSet<PathBuf>, std::io::Error> {\n        let dependencies = self.invalidate_document(path);\n        self.all_documents.docs.remove(path);\n        self.bump_revision();\n\n        if self.all_documents.currently_loading.contains_key(path) {\n            Err(std::io::Error::new(ErrorKind::InvalidInput, format!(\"{path:?} is still loading\")))\n        } else {\n            Ok(dependencies)\n        }\n    }\n\n    /// Invalidate a document and all its dependencies.\n    ///\n    /// This will keep the CST of the document in cache, but mark that it needs to be re-analyzed\n    /// to reconstruct its types.\n    ///\n    /// To entirely forget a document and cause a complete re-parse, use [Self::drop_document].\n    pub fn invalidate_document(&mut self, path: &Path) -> HashSet<PathBuf> {\n        if let Some((d, _)) = self.all_documents.docs.get_mut(path) {\n            if let LoadedDocument::Document(doc) = d {\n                for import in &doc.imports {\n                    self.all_documents\n                        .dependencies\n                        .entry(Path::new(&import.file).into())","sourceCodeStart":1000,"sourceCodeEnd":1036,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/typeloader.rs#L1000-L1036","documentation":"drop_document removes a compiled document and its registry entry, but refuses to do so while the compiler is still asynchronously loading that path (currently_loading map). Dropping would corrupt the loading pipeline's bookkeeping, so it returns an InvalidInput io::Error instead.","triggerScenarios":"Calling TypeLoader::drop_document(path) while a load/future for that same path is in flight (path is in self.all_documents.currently_loading).","commonSituations":"Hot-reload or LSP flows where a file change triggers reload while the previous load's async I/O hasn't finished; user closes/edits a document faster than the compiler resolves imports.","solutions":["Wait until the pending load completes (or fails) before calling drop_document.","Cancel or drain the in-flight load first; drop_document again after currently_loading no longer contains the path.","Ignore the error and retry later — the document is left intact."],"exampleFix":"// before\nloader.drop_document(&path).unwrap();\n// after\nmatch loader.drop_document(&path) {\n    Ok(deps) => { /* proceed */ }\n    Err(e) if e.kind() == std::io::ErrorKind::InvalidInput => {\n        // still loading; retry after the load future resolves\n    }\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"try-catch","validationCode":"// guard: only drop when not currently loading\nif !loader.all_documents.currently_loading.contains_key(path) { loader.drop_document(path)?; }","typeGuard":null,"tryCatchPattern":"match loader.drop_document(&path) {\n    Ok(deps) => /* proceed */,\n    Err(e) if e.kind() == ErrorKind::InvalidInput => /* retry after load completes */,\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Track in-flight loads in your editor integration and defer drop_document until they resolve.","Serialize document mutations (load/drop) through one event loop to avoid races."],"tags":["compiler","async","state-conflict","rust"],"backgroundTag":"invalid-state-transition","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}