The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 21:00 UTC
fix(desktop): stalled update downloads time out and say why (#26244)
Julius Marminge committed
Nov 11, 2026 at 20:29 UTC
d353fba97eb48cebc63258e4271416a3667346a8
9 files changed
+142
-16
apps/desktop/package.json
+1
-1
@@ -24,7 +24,7 @@
24
"effect": "catalog:",
25
"electron": "44.10.1",
26
"electron-store": "^8.2.0",
27
- "electron-updater": "^6.8.9",
27
+ "electron-updater": "6.8.9",
28
"electron-webauthn": "catalog:",
29
"ffi-rs": "1.3.2",
30
"playwright-core": "1.64.1",
apps/desktop/src/electron/ElectronHttpExecutor.test.ts
new
+59
@@ -0,0 +1,59 @@
1
+// @effect-diagnostics nodeBuiltinImport:off -- Fake Electron net request and response emitters.
2
+import * as NodeEvents from "node:events";
3
+import { ElectronHttpExecutor } from "electron-updater/out/electronHttpExecutor.js";
4
+import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
5
+
6
+function startRequest() {
7
+ const request = Object.assign(new NodeEvents.EventEmitter(), { abort: vi.fn() });
8
+ const response = new NodeEvents.EventEmitter();
9
+ const reject = vi.fn();
10
+ new ElectronHttpExecutor().addErrorAndTimeoutHandlers(request, reject);
11
+ // Electron's net.ClientRequest emits these as soon as the request body is sent, before any response.
12
+ request.emit("finish");
13
+ request.emit("close");
14
+ return { request, response, reject };
15
+}
16
+
17
+describe("ElectronHttpExecutor idle timeout", () => {
18
+ beforeEach(() => {
19
+ vi.useFakeTimers();
20
+ });
21
+ afterEach(() => {
22
+ vi.useRealTimers();
23
+ });
24
+
25
+ it("aborts a request that receives no response for 60 seconds", () => {
26
+ const { request, reject } = startRequest();
27
+
28
+ vi.advanceTimersByTime(59_999);
29
+ expect(reject).not.toHaveBeenCalled();
30
+ vi.advanceTimersByTime(1);
31
+
32
+ expect(request.abort).toHaveBeenCalledOnce();
33
+ expect(reject).toHaveBeenCalledWith(new Error("Request timed out"));
34
+ });
35
+
36
+ it("keeps a slow download alive while data keeps arriving", () => {
37
+ const { request, response, reject } = startRequest();
38
+ request.emit("response", response);
39
+
40
+ for (let elapsed = 0; elapsed < 180_000; elapsed += 30_000) {
41
+ vi.advanceTimersByTime(30_000);
42
+ response.emit("data", Buffer.alloc(1));
43
+ }
44
+
45
+ expect(request.abort).not.toHaveBeenCalled();
46
+ expect(reject).not.toHaveBeenCalled();
47
+ });
48
+
49
+ it("stops the timer once the response ends", () => {
50
+ const { request, response, reject } = startRequest();
51
+ request.emit("response", response);
52
+
53
+ response.emit("end");
54
+ vi.advanceTimersByTime(600_000);
55
+
56
+ expect(request.abort).not.toHaveBeenCalled();
57
+ expect(reject).not.toHaveBeenCalled();
58
+ });
59
+});
apps/desktop/src/updates/DesktopUpdates.test.ts
+27
@@ -426,6 +426,33 @@ describe("DesktopUpdates", () => {
426
).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
427
});
428
429
+ it.effect("shows why a download failed, not only the channel", () => {
430
+ const harness = makeHarness({
431
+ downloadUpdate: Effect.fail(
432
+ new ElectronUpdater.ElectronUpdaterDownloadUpdateError({
433
+ channel: "nightly",
434
+ cause: new Error("net::ERR_CONTENT_LENGTH_MISMATCH"),
435
+ }),
436
+ ),
437
+ });
438
+
439
+ return Effect.scoped(
440
+ Effect.gen(function* () {
441
+ const updates = yield* DesktopUpdates.DesktopUpdates;
442
+ yield* updates.configure;
443
+ harness.emit("update-available", { version: "1.2.4" });
444
+ yield* flushCallbacks;
445
+
446
+ const result = yield* updates.download;
447
+ assert.isFalse(result.completed);
448
+
449
+ const state = yield* updates.getState;
450
+ assert.equal(state.errorContext, "download");
451
+ assert.include(state.message ?? "", "ERR_CONTENT_LENGTH_MISMATCH");
452
+ }),
453
+ ).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
454
+ });
455
+
456
it.effect("restores download state and permits retry after interruption", () =>
457
Effect.gen(function* () {
458
const actionStarted = yield* Deferred.make<void>();
apps/desktop/src/updates/DesktopUpdates.ts
+3
-2
@@ -614,12 +614,13 @@ export const make = Effect.gen(function* () {
614
Effect.catchTags({
615
ElectronUpdaterDownloadUpdateError: Effect.fn("desktop.updates.handleDownloadFailure")(
616
function* (error) {
617
+ const cause = describeUpdateErrorCause(error.cause);
618
yield* updateState((current) =>
618
- reduceDesktopUpdateStateOnDownloadFailure(current, error.message),
619
+ reduceDesktopUpdateStateOnDownloadFailure(current, `${error.message} ${cause}`),
620
);
621
yield* logUpdaterError(error.message, {
622
errorTag: error._tag,
622
- cause: describeUpdateErrorCause(error.cause),
623
+ cause,
624
channel: error.channel,
625
});
626
return { accepted: true, completed: false };
apps/desktop/src/updates/updatesTestHarness.ts
+1
-1
@@ -27,7 +27,7 @@ export interface UpdatesHarnessOptions {
27
readonly beforeSetUpdateChannel?: Effect.Effect<void>;
28
readonly setUpdateChannelError?: DesktopAppSettings.DesktopSettingsWriteError;
29
readonly setDisableDifferentialDownload?: Effect.Effect<void>;
30
- readonly downloadUpdate?: Effect.Effect<void>;
30
+ readonly downloadUpdate?: Effect.Effect<void, ElectronUpdater.ElectronUpdaterDownloadUpdateError>;
31
readonly quitAndInstall?: Effect.Effect<void, ElectronUpdater.ElectronUpdaterQuitAndInstallError>;
32
readonly stopBackend?: Effect.Effect<void>;
33
readonly startBackend?: Effect.Effect<void>;
apps/web/src/components/settings/SettingsPanels.tsx
+2
-9
@@ -116,6 +116,7 @@ import { environmentIdsKey } from "~/state/environmentAtomList";
116
import { environmentSessionStatesAtom } from "~/state/session";
117
import { useCheckProviderUpdates } from "../ProviderUpdatesAction";
118
import { canUpdateServer } from "../ServerUpdateAction";
119
+import { downloadLocalUpdate } from "../sidebar/SidebarUpdatePill";
120
import { useUpdateEverythingRun } from "../sidebar/updateEverythingRun";
121
import { awaitsTrackSwitch, channelSwitchLabel } from "../sidebar/updateEverything.logic";
122
import { isHostedByThisApp } from "../sidebar/useUpdateEverything";
@@ -205,15 +206,7 @@ function AboutVersionSection() {
206
const action = updateState ? resolveDesktopUpdateButtonAction(updateState) : "none";
207
208
if (action === "download") {
208
- void bridge.downloadUpdate().catch((error: unknown) => {
209
- toastManager.add(
210
- stackedThreadToast({
211
- type: "error",
212
- title: "Could not download update",
213
- description: error instanceof Error ? error.message : "Download failed.",
214
- }),
215
- );
216
- });
209
+ void downloadLocalUpdate(bridge, { notifyDownloaded: false });
210
return;
211
}
212
patches/electron-updater@6.8.9.patch
new
+40
@@ -0,0 +1,40 @@
1
+diff --git a/out/electronHttpExecutor.js b/out/electronHttpExecutor.js
2
+index 0ae9e1126e1dc136977914ef1bfd46709fc9db1b..3932b6607ca41e6663aae001111c9b18594ed37a 100644
3
+--- a/out/electronHttpExecutor.js
4
++++ b/out/electronHttpExecutor.js
5
+@@ -61,6 +61,35 @@ class ElectronHttpExecutor extends builder_util_runtime_1.HttpExecutor {
6
+ }
7
+ return request;
8
+ }
9
++ // Electron's net.ClientRequest never emits "socket", so the inherited socket idle timeout never
10
++ // arms and a stalled request stays pending forever. Reset an idle timer on every chunk instead.
11
++ addTimeOutHandler(request, callback, timeout) {
12
++ let timer = null;
13
++ const clear = () => {
14
++ if (timer != null) {
15
++ clearTimeout(timer);
16
++ timer = null;
17
++ }
18
++ };
19
++ const arm = () => {
20
++ clear();
21
++ timer = setTimeout(() => {
22
++ timer = null;
23
++ request.abort();
24
++ callback(new Error("Request timed out"));
25
++ }, timeout);
26
++ };
27
++ request.on("response", (response) => {
28
++ arm();
29
++ response.on("data", arm);
30
++ response.on("end", clear);
31
++ response.on("aborted", clear);
32
++ response.on("error", clear);
33
++ });
34
++ request.on("abort", clear);
35
++ request.on("error", clear);
36
++ arm();
37
++ }
38
+ addRedirectHandlers(request, options, reject, redirectCount, handler) {
39
+ request.on("redirect", (statusCode, method, redirectUrl) => {
40
+ // no way to modify request options, abort old and make a new one
pnpm-lock.yaml
+5
-3
@@ -295,6 +295,7 @@ overrides:
295
react-native-webview: 14.0.1
296
react-native-svg: 15.16.1
297
app-builder-lib: 26.16.1
298
+ electron-updater: 6.8.9
299
expo-modules-core: 58.0.30
300
'@exodus/bytes>@noble/hashes': 1.8.0
301
'@react-navigation/core': 7.24.0
@@ -370,6 +371,7 @@ patchedDependencies:
371
alchemy@2.0.0-beta.85: 07cc8c7e14b3b9af143ddd40a059f117c27e55139fbf20bd5dde2eb30509cedd
372
app-builder-lib@26.16.1: 0fbe9ae51783f5768ebe197d12d1fdb7d477a08c92e5db2f6356bcce62613c53
373
dbus-next@0.10.2: cfff57561b0ee59b5addb3b2e6c6f20906e967507a530ab67e8db8108e520ba4
374
+ electron-updater@6.8.9: 2ed21db470f254c5e095a0eb8dabc086c310d180322004bceee7d56e7ce86b84
375
expo-audio@58.0.11: 93691f7f59edb30a3bb2c23b489e605e7ea35506b1212d4a2ebbd1fd79079483
376
expo-modules-core@58.0.30: f0b0fd100550ed76e5c25b4d13eb7c9ff62825f8f197c53edf7bf447c50c9fb7
377
expo-network@58.0.4: 159c2d760d1cd5102e95df51c20600111e7a72096ef0daea8215d50cae48bd98
@@ -458,8 +460,8 @@ importers:
460
specifier: ^8.2.0
461
version: 8.2.0
462
electron-updater:
461
- specifier: ^6.8.9
462
- version: 6.8.9(supports-color@8.1.1)
463
+ specifier: 6.8.9
464
+ version: 6.8.9(patch_hash=2ed21db470f254c5e095a0eb8dabc086c310d180322004bceee7d56e7ce86b84)(supports-color@8.1.1)
465
electron-webauthn:
466
specifier: 'catalog:'
467
version: 1.3.1(typescript@6.0.3)
@@ -19005,7 +19007,7 @@ snapshots:
19007
19008
electron-to-chromium@1.5.430: {}
19009
19008
- electron-updater@6.8.9(supports-color@8.1.1):
19010
+ electron-updater@6.8.9(patch_hash=2ed21db470f254c5e095a0eb8dabc086c310d180322004bceee7d56e7ce86b84)(supports-color@8.1.1):
19011
dependencies:
19012
builder-util-runtime: 9.7.0(supports-color@8.1.1)
19013
fs-extra: 10.1.0
pnpm-workspace.yaml
+4
@@ -129,6 +129,7 @@ overrides:
129
react-native-webview: 14.0.1
130
react-native-svg: 15.16.1
131
app-builder-lib: 26.16.1
132
+ electron-updater: 6.8.9
133
expo-modules-core: 58.0.30
134
# Keep jsdom's optional peer consistent so Vite+ has one test-runner instance.
135
"@exodus/bytes>@noble/hashes": "1.8.0"
@@ -256,6 +257,9 @@ patchedDependencies:
257
# Observe the owned host exit independently of descendants retaining its stdio.
258
"@muse-code/sdk@1.4.6": patches/@muse-code__sdk@1.4.6.patch
259
app-builder-lib@26.16.1: patches/app-builder-lib@26.16.1.patch
260
+ # Electron net requests never emit "socket", so upstream's idle timeout never fires and a
261
+ # stalled update download hangs forever.
262
+ electron-updater@6.8.9: patches/electron-updater@6.8.9.patch
263
# Local agents honor the attribution settings in the user's Cursor CLI cli-config.json.
264
"@cursor/sdk@1.2.0": patches/@cursor__sdk@1.2.0.patch
265
# A failed Artifacts.cached effect hangs every later caller: https://github.com/alchemy-run/alchemy/issues/2981