From f7cf7c8adce8f53cab93a4f6b84198ae3880e424 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Thu, 12 Feb 2026 20:05:27 +0100 Subject: [PATCH] fix(telemetry): prevent stuck 'installing' status in error_handler.func (#11845) The catch_errors() function in CT scripts overrides the API telemetry traps set by build.func. This caused on_exit, on_interrupt, and on_terminate to never call post_update_to_api, leaving telemetry records permanently stuck on 'installing'. Changes: - on_exit: Report orphaned 'installing' records on ANY exit where post_to_api was called but post_update_to_api was not - on_interrupt: Call post_update_to_api('failed', '130') before exit - on_terminate: Call post_update_to_api('failed', '143') before exit All calls are guarded by POST_UPDATE_DONE flag to prevent duplicates. --- misc/error_handler.func | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/misc/error_handler.func b/misc/error_handler.func index 87c2b4883..2dea84742 100644 --- a/misc/error_handler.func +++ b/misc/error_handler.func @@ -243,6 +243,18 @@ error_handler() { # ------------------------------------------------------------------------------ on_exit() { local exit_code=$? + # Report orphaned "installing" records to telemetry API + # Catches ALL exit paths: errors (non-zero), signals, AND clean exits where + # post_to_api was called ("installing" sent) but post_update_to_api was never called + if [[ "${POST_TO_API_DONE:-}" == "true" && "${POST_UPDATE_DONE:-}" != "true" ]]; then + if declare -f post_update_to_api >/dev/null 2>&1; then + if [[ $exit_code -ne 0 ]]; then + post_update_to_api "failed" "$exit_code" + else + post_update_to_api "failed" "1" + fi + fi + fi [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" exit "$exit_code" } @@ -255,6 +267,10 @@ on_exit() { # - Exits with code 130 (128 + SIGINT=2) # ------------------------------------------------------------------------------ on_interrupt() { + # Report interruption to telemetry API (prevents stuck "installing" records) + if declare -f post_update_to_api >/dev/null 2>&1; then + post_update_to_api "failed" "130" + fi if declare -f msg_error >/dev/null 2>&1; then msg_error "Interrupted by user (SIGINT)" else @@ -272,6 +288,10 @@ on_interrupt() { # - Triggered by external process termination # ------------------------------------------------------------------------------ on_terminate() { + # Report termination to telemetry API (prevents stuck "installing" records) + if declare -f post_update_to_api >/dev/null 2>&1; then + post_update_to_api "failed" "143" + fi if declare -f msg_error >/dev/null 2>&1; then msg_error "Terminated by signal (SIGTERM)" else