Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
spaces-desktop: catch handled update-download failures, log their real reason (CUA-3304) (#6460)
cua-agents[bot]5a40f4890599
diff --git a/apps/cua-spaces-desktop/src/update-error.ts b/apps/cua-spaces-desktop/src/update-error.tsnew file mode 100644index 0000000000..3a4f1bef5e--- /dev/null+++ b/apps/cua-spaces-desktop/src/update-error.ts@@ -0,0 +1,41 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++// A failed update check or download is handled (Settings → About shows it),+// so it is logged with its reason, not left to Sentry's global handlers as a+// crash. electron-updater's errors can have an empty message (the NSIS+// download failure on Windows), so the reason is built from the error's name,+// code, HTTP status and the URL's host (never the path or query).++interface UpdateErrorLike {+ name?: unknown;+ message?: unknown;+ code?: unknown;+ statusCode?: unknown;+ url?: unknown;+}++const hostOf = (value: unknown): string | null => {+ if (typeof value !== "string") return null;+ const found = /https?:\/\/[^\s"'<>)]+/.exec(value)?.[0];+ if (!found) return null;+ try {+ return new URL(found).host;+ } catch {+ return null;+ }+};++/** A readable reason for a handled update failure; never empty. */+export function describeUpdateError(error: unknown): string {+ const e: UpdateErrorLike = error !== null && typeof error === "object" ? (error as UpdateErrorLike) : { message: String(error ?? "") };+ const message = typeof e.message === "string" ? e.message.trim() : "";+ const parts: string[] = [];+ if (typeof e.code === "string" || typeof e.code === "number") parts.push(`code ${e.code}`);+ if (typeof e.statusCode === "number") parts.push(`HTTP ${e.statusCode}`);+ const host = hostOf(e.url) ?? hostOf(message);+ if (host) parts.push(`host ${host}`);+ const name = typeof e.name === "string" && e.name ? e.name : "Error";+ const head = message || `${name} with no message`;+ return parts.length ? `${head} (${parts.join(", ")})` : head;+}diff --git a/apps/cua-spaces-desktop/src/updater.ts b/apps/cua-spaces-desktop/src/updater.tsindex 4c6ff65e8b..b1b2b2bbcf 100644--- a/apps/cua-spaces-desktop/src/updater.ts+++ b/apps/cua-spaces-desktop/src/updater.ts@@ -26,6 +26,7 @@ import { existsSync } from "node:fs";import * as path from "node:path";import { electronUpdater } from "./electron-updater";import type { UpdaterDriving } from "./model/updates";+import { describeUpdateError } from "./update-error";import { readSettings, writeSettings } from "./settings";import { autoCheckPref, autoInstallPref, channelPref, type UpdateChannel } from "./update-prefs";import { initialUpdateState, reduceUpdate, UPDATE_POLL_MS, UPDATE_STARTUP_DELAY_MS, type UpdateEvent, type UpdateStateValue } from "./update-state";@@ -211,7 +212,15 @@ export class ElectronUpdater implements UpdaterDriving {this.onChange?.();try {const u = await this.updater();- await u.checkForUpdates();+ const result = await u.checkForUpdates();+ // autoDownload starts the download behind this check and hands back its+ // promise. Nothing awaits it (a check ends when the update is found), so+ // a failed download would reject unhandled and Sentry would report it as+ // a crash. It is a handled failure: the "error" event has already fed+ // the state machine; this only catches the rejection.+ result?.downloadPromise?.catch((error: unknown) => {+ if (!this.reported) this.failed(error instanceof Error ? error : new Error(String(error)));+ });} catch (error) {if (!this.reported) this.failed(error instanceof Error ? error : new Error(String(error)));} finally {@@ -247,9 +256,10 @@ export class ElectronUpdater implements UpdaterDriving {this.onUpdateEvent?.("failed");const user = this.userCheck || install;this.userCheck = false;- console.warn(`[cua-spaces] update: ${error.message}`);- this.report({ type: "error", message: error.message });+ const reason = describeUpdateError(error);+ console.warn(`[cua-spaces] update: ${reason}`);+ this.report({ type: "error", message: reason });if (!user) return;- void message({ type: "warning", message: "Update Error!", detail: `An error occurred while updating: ${error.message}`, buttons: ["OK"] });+ void message({ type: "warning", message: "Update Error!", detail: `An error occurred while updating: ${reason}`, buttons: ["OK"] });}}diff --git a/apps/cua-spaces-desktop/test/update-error.test.ts b/apps/cua-spaces-desktop/test/update-error.test.tsnew file mode 100644index 0000000000..9338799c0c--- /dev/null+++ b/apps/cua-spaces-desktop/test/update-error.test.ts@@ -0,0 +1,23 @@+// SPDX-License-Identifier: FSL-1.1-MIT+// Copyright (c) 2026 Cua AI, Inc.++import { describe, expect, it } from "vitest";+import { describeUpdateError } from "../src/update-error";++describe("describeUpdateError", () => {+ it("never returns an empty reason", () => {+ expect(describeUpdateError(new Error(""))).toBe("Error with no message");+ expect(describeUpdateError(undefined)).toBe("Error with no message");+ });++ it("carries the code, HTTP status and URL host, not the path or query", () => {+ const e = Object.assign(new Error(""), { code: "ERR_UPDATER_INVALID_RELEASE_FEED", statusCode: 404, url: "https://github.com/trycua/cua/releases/download/x/app.exe?token=secret" });+ expect(describeUpdateError(e)).toBe("Error with no message (code ERR_UPDATER_INVALID_RELEASE_FEED, HTTP 404, host github.com)");+ });++ it("finds the host in the message and keeps the message", () => {+ expect(describeUpdateError(new Error("net::ERR_FAILED https://objects.example.com/a/b?sig=1"))).toBe(+ "net::ERR_FAILED https://objects.example.com/a/b?sig=1 (host objects.example.com)",+ );+ });+});