{"record":{"id":"8522387b9c24aa22","repo":"FyroxEngine/Fyrox","slug":"build-was-cancelled","errorCode":null,"errorMessage":"Build was cancelled.","messagePattern":"Build was cancelled\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"fyrox-build-tools/src/export/mod.rs","lineNumber":117,"sourceCode":"        TargetPlatform::Android => {\n            android::build_package(package_name, build_target, enable_optimization)\n        }\n    };\n\n    let mut handle = match process.spawn() {\n        Ok(handle) => handle,\n        Err(err) => {\n            return Err(format!(\"Failed to build the game. Reason: {err:?}\"));\n        }\n    };\n\n    let mut stderr = handle.stderr.take().unwrap();\n\n    // Spin until the build is finished.\n    loop {\n        if cancel_flag.load(Ordering::Relaxed) {\n            Log::verify(handle.kill());\n            Log::warn(\"Build was cancelled.\");\n            return Ok(());\n        }\n\n        for line in BufReader::new(&mut stderr).lines().take(10).flatten() {\n            Log::writeln(MessageKind::Information, line);\n        }\n\n        match handle.try_wait() {\n            Ok(status) => {\n                if let Some(status) = status {\n                    let code = status.code().unwrap_or(1);\n                    if code != 0 {\n                        return Err(\"Failed to build the game.\".to_string());\n                    } else {\n                        Log::info(\"The game was built successfully.\");\n                        break;\n                    }\n                }","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-build-tools/src/export/mod.rs#L99-L135","documentation":"During export, build_package spawns a build process and polls a cancellation flag on a loop reading the build's stderr. If the flag is set, the child process is killed and the function returns Ok(()) with this warning. It is not an error — it is the normal (graceful) cancellation path of an in-progress build.","triggerScenarios":"Another thread/task sets the shared cancel_flag (e.g. user pressed Cancel in the editor) while build_package is streaming stderr from the running cargo/build process.","commonSituations":"User cancels a long-running export/build in the Fyrox editor; build takes too long and the user aborts; app shutdown cancels in-flight build tasks.","solutions":["Treat this as expected cancellation: check the cancel flag path and just proceed/retry when needed.","If the build should never be cancelled, audit who sets the AtomicBool cancel flag (UI cancel button, shutdown hooks) and remove or guard those writers.","Rerun the export when cancellation was accidental; no state is corrupted because the child process was killed via handle.kill().","Make cancellation explicit in your UI/log so users know a build was aborted rather than failed."],"exampleFix":"// before\nlet cancel_flag = Arc::new(AtomicBool::new(false));\n// accidental: some handler sets it on any UI event\nui.on(Event::Any).execute(move |_| { flag.store(true, Ordering::Relaxed); true });\n// after\nlet cancel_flag = Arc::new(AtomicBool::new(false));\n// only set on explicit Cancel button click\nui.on(ButtonMessage::Click).for_widget(cancel_btn).execute(move |_| { flag.store(true, Ordering::Relaxed); true });","handlingStrategy":"try-catch","validationCode":"// check before starting a build\nif cancel_flag.load(Ordering::Relaxed) {\n    return; // don't start a build that will be cancelled\n}","typeGuard":null,"tryCatchPattern":"// cancellation is reported via Ok(()) + log, not an error\nbuild_package(...)?; // returns Ok on cancel\nif cancel_flag.load(Ordering::Relaxed) {\n    log::info!(\"Build was cancelled; skipping post-build steps\");\n}","preventionTips":["Only set the cancel flag from explicit user-cancel actions","Check the flag before launching long builds","Log cancellations distinctly from failures in CI","On shutdown, drain in-flight builds before dropping the flag"],"tags":["build","cancellation","export","async"],"backgroundTag":"operation-cancelled","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"}