Files
open-design/apps/desktop/tests
Chris SeifertandGitHub a1742e2fa9 fix(desktop): recover the window when the renderer dies or a load fails (#4179)
* fix(desktop): recover the window when the renderer dies or a load fails

The main window's poll loader only calls loadURL when the discovered web
URL changes, so a renderer that dies after a successful load is never
reloaded. The render-process-gone handler only reported the crash to
analytics, and there was no did-fail-load handler, so a failed main-frame
load left the renderer parked on chrome-error:// (blank white) with no
retry. That is the blank window after minimizing and restoring the app:
the OS reclaims the backgrounded renderer or its connection drops, and
nothing brings it back.

Add a rendererFailed flag set by did-fail-load (ignoring -3 aborts) and by
a non-clean render-process-gone, and have the poll loop reload the current
URL while the flag is set, clearing it on a successful load. When the web
server is still unreachable, discovery returns null and the loop backs off
to its normal interval until it returns.

Verified in the running app: forcing the renderer to a refused port parks
it on chrome-error, then the next poll reloads it back to the mounted app.

* fix(desktop): keep a single poll loop when a renderer load fails mid-tick

markRendererFailed scheduled its own prompt retry, but a loadURL that rejects inside tick fires did-fail-load AND falls into tick's catch, so both queued a poll timer and the loop forked into two (multiplying on each repeated failure). Track whether a tick is in flight and have the failure handler only flip the rendererFailed flag while one is running, leaving tick as the sole rescheduler. An idle renderer death still reschedules promptly.

Adds a source-assertion regression test in the window-chrome.test.ts style, since the loop lives inside createDesktopRuntime and has no behavioral seam under vitest.

Addresses review feedback on #4179.
2026-06-13 12:49:32 +00:00
..