{"record":{"id":"a8a140dfa2866133","repo":"FyroxEngine/Fyrox","slug":"there-is-a-script-instance-on-a-node-but-no-me","errorCode":null,"errorMessage":"There is a script instance on a node {}, but no message sender. The script won't be correctly destroyed!","messagePattern":"There is a script instance on a node (.+?), but no message sender\\. The script won't be correctly destroyed!","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"fyrox-impl/src/scene/base.rs","lineNumber":895,"sourceCode":"    /// update tick of the parent graph.\n    pub fn remove_script(&mut self, index: usize) {\n        // Send script to the graph to destroy script instances correctly.\n        if let Some(entry) = self.scripts.get_mut(index) {\n            entry.should_be_deleted = true;\n\n            // We might be in a middle of a script method execution, where script is temporarily\n            // extracted from the array.\n            if let Some(script) = entry.take() {\n                if let Some(senders) = self.senders.as_ref() {\n                    Log::verify(senders.script_message_sender.send(\n                        NodeScriptMessage::DestroyScript {\n                            script,\n                            handle: self.self_handle,\n                            script_index: index,\n                        },\n                    ));\n                } else {\n                    Log::warn(format!(\n                        \"There is a script instance on a node {}, but no message sender. \\\n                    The script won't be correctly destroyed!\",\n                        self.name(),\n                    ));\n                }\n            }\n        }\n    }\n\n    /// Removes all assigned scripts from the scene node. The scripts will be removed from\n    /// first-to-last order an their actual destruction will happen either on the current update tick\n    /// of the parent graph (if it was removed from some other script) or in the next update tick.\n    pub fn remove_all_scripts(&mut self) {\n        let script_count = self.scripts.len();\n        for i in 0..script_count {\n            self.remove_script(i);\n        }\n    }","sourceCodeStart":877,"sourceCodeEnd":913,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-impl/src/scene/base.rs#L877-L913","documentation":"When a scene node is destroyed, each of its script instances should receive a DestroyScriptMessage via the engine's message sender so the script can clean up. If the node has a script instance but no message sender is available at that point, Fyrox logs this warning because the script's destructor logic won't run. Resources held by the script (entities, GPU handles, network connections) may leak.","triggerScenarios":"Deleting a node (or its subtree) whose Script Decompile path executes while self message sender is None — e.g. destroying nodes during graph teardown phases where the sender was already dropped or never provided.","commonSituations":"Removing nodes during engine shutdown or inside another script's teardown; constructing/destroying nodes outside the normal update loop where the message sender context is unavailable.","solutions":["Ensure nodes with scripts are destroyed via the normal Scene API (remove_node) during the update loop so a message sender is present.","Avoid destroying scripted nodes during graph destruction/shutdown; free resources in the script's on_removed or Drop if teardown-time destruction is unavoidable.","Review custom code paths that clone/detach ScriptDecompile logic without propagating the sender."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only remove scripted nodes via scene.remove_node during the normal update loop.","Don't destroy nodes during shutdown/teardown; rely on script Drop/on_removed cleanup.","Free critical resources in on_removed so leaks are bounded if destroy messages are missed."],"tags":["fyrox","scripts","scene-graph","resource-leak"],"backgroundTag":"invalid-state-transition","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}