@devries-cameron20 / t3code Mirror · read-only / commits / 3e7f5ecc55
Fork 0

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, 11:00 UTC

fix(desktop): a renderer that keeps crashing is reloaded with a backoff instead of left blank (#37240)

Julius Marminge committed Nov 15, 2026 at 06:57 UTC 3e7f5ecc55c532ce60e6b1c48f210e17f3c8c9d1
2 files changed +51 -6
apps/desktop/src/window/DesktopWindow.test.ts
+32
@@ -1226,6 +1226,38 @@ describe("DesktopWindow", () => {
1226 }),
1227 );
1228
1229 + it.effect(
1230 + "brings the window back after the renderer dies more often than the reload budget",
1231 + () =>
1232 + Effect.gen(function* () {
1233 + const fakeWindow = makeFakeBrowserWindow();
1234 + const createCount = yield* Ref.make(0);
1235 + const mainWindow = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
1236 + const layer = layerTest({ window: fakeWindow.window, createCount, mainWindow });
1237 +
1238 + yield* Effect.gen(function* () {
1239 + const desktopWindow = yield* DesktopWindow.DesktopWindow;
1240 + yield* desktopWindow.handleBackendReady(new URL("http://127.0.0.1:3773"));
1241 +
1242 + const renderProcessGone = fakeWindow.webContentsListeners.get("render-process-gone");
1243 + if (!renderProcessGone) {
1244 + return yield* Effect.die("render-process-gone listener was not registered");
1245 + }
1246 + for (let crash = 1; crash <= 4; crash++) {
1247 + const loadsBefore = fakeWindow.loadURL.mock.calls.length;
1248 + renderProcessGone({}, { reason: "oom", exitCode: -536870904 });
1249 + yield* TestClock.adjust(crash < 4 ? 1_000 : 60_000);
1250 + yield* Effect.promise(() => Promise.resolve());
1251 + assert.isAbove(
1252 + fakeWindow.loadURL.mock.calls.length,
1253 + loadsBefore,
1254 + `window shows nothing after renderer crash ${crash}`,
1255 + );
1256 + }
1257 + }).pipe(Effect.provide(layer));
1258 + }),
1259 + );
1260 +
1261 it.effect("updates title bar overlays only on windows created with one", () =>
1262 Effect.gen(function* () {
1263 const framed = makeFakeBrowserWindow();
apps/desktop/src/window/DesktopWindow.ts
+19 -6
@@ -942,20 +942,33 @@ export const make = Effect.gen(function* () {
942 rendererRecoveryTimestamps = rendererRecoveryTimestamps.filter(
943 (timestamp) => now - timestamp < RENDERER_RECOVERY_WINDOW_MS,
944 );
945 - const shouldRecover =
946 - recoverable &&
947 - !window.isDestroyed() &&
948 - rendererRecoveryTimestamps.length < RENDERER_RECOVERY_MAX_ATTEMPTS;
945 + const shouldRecover = recoverable && !window.isDestroyed();
946 + // Past the budget, wait for the oldest attempt to leave the window instead of
947 + // giving up, so a crash loop backs off but never leaves the window blank.
948 + const oldestAttempt =
949 + rendererRecoveryTimestamps.length >= RENDERER_RECOVERY_MAX_ATTEMPTS
950 + ? rendererRecoveryTimestamps[
951 + rendererRecoveryTimestamps.length - RENDERER_RECOVERY_MAX_ATTEMPTS
952 + ]
953 + : undefined;
954 + const reloadInMs =
955 + oldestAttempt === undefined
956 + ? RENDERER_RECOVERY_RELOAD_DELAY_MS
957 + : Math.max(
958 + RENDERER_RECOVERY_RELOAD_DELAY_MS,
959 + oldestAttempt + RENDERER_RECOVERY_WINDOW_MS - now,
960 + );
961 yield* logWindowWarning("main window render process gone", {
962 reason: details.reason,
963 exitCode: details.exitCode,
964 recovering: shouldRecover,
965 + ...(shouldRecover ? { reloadInMs } : {}),
966 });
967 if (!shouldRecover) {
968 return;
969 }
957 - rendererRecoveryTimestamps.push(now);
958 - yield* Effect.sleep(RENDERER_RECOVERY_RELOAD_DELAY_MS);
970 + rendererRecoveryTimestamps.push(now + reloadInMs);
971 + yield* Effect.sleep(reloadInMs);
972 if (!window.isDestroyed()) {
973 loadApplication();
974 }