Desktop (Windows): startup blocked by junction backup (EPERM), blank WebContentsView, and watchdog kills during indexing
Environment
- Open DeepTutor desktop 1.7.3 (Windows x64), upgraded in place 1.7.1 → 1.7.2 → 1.7.3
- Windows 11 24H2, build 26300, x64
- Bundled runtime
1.7.3-4c1e000d8-x64 - Data folder:
%LOCALAPPDATA%\Open DeepTutor\workspace(the entire app data dir is itself a junction to another drive);workspace\datawas a junction to a separate disk.
Symptoms
- After installing 1.7.3 the app never starts: splash / blank window, core may come up briefly then disappear.
- On an earlier 1.7.2 → 1.7.3 attempt,
workspace\datawas silently replaced by an empty directory — the user's sessions and knowledge bases appeared to be gone. - When it does start, the window often shows a blank white content area (only the title bar and menu). Maximizing the window makes the UI appear immediately.
- Clicking the desktop/taskbar icon while the window is minimized does nothing — the window stays minimized.
Root causes (logs + source)
A. Upgrade backup aborts when the data folder is a junction
apps/desktop/src/main.mjs (1.7.3), boot():
try { await cp(runtimeHome, backup, { recursive: true }); }
When runtimeHome/data is a Windows junction, fs.cp tries to recreate it as a symlink and fails on a non-elevated account:
Desktop startup failed: Error: EPERM: operation not permitted, symlink
'E:\...\data' -> 'C:\Users\...\backups\before-1.7.3-4c1e000d8-x64-1794796910400\data'
at async symlink (node:internal/fs/promises:1714:10)
at async copyDir (node:internal/fs/cp/cp:336:19)
at async mkDirAndCopy (node:internal/fs/cp/cp:322:3)
at async boot (.../main.mjs:262:13)
Every launch retries and aborts; there is no fallback. An earlier attempt left a fresh empty data directory, which is how the workspace looked lost.
Suggested: copy junction contents (dereference: true) or detect reparse points and recreate the junction; treat a backup failure as non-fatal (backup = undefined + warning) rather than aborting startup.
B. Blank WebContentsView after restore
openContent() adds the view and calls layout() once; only window.on('resize', layout) is registered. If the view is added while the window is minimized/occluded, it is never painted, and restoring the window does not repaint it (a resize/maximize does).
Suggested: call layout() on restore, show, focus, maximize, and after await content.loadURL(url); optionally nudge the view bounds by 1px to force a repaint.
C. second-instance does not restore a minimized window
app.on('second-instance', () => { window?.show(); window?.focus(); });
show() on a minimized window leaves it minimized, so relaunching the app appears to do nothing.
Suggested: if (window.isMinimized()) window.restore(); before show()/focus().
D. Health watchdog kills the core during indexing
apps/desktop/src/runtime.mjs probes /health/ready every 10 s and after 3 misses calls fail() → taskkill of the runtime. Rebuilding a large KB (AgentBooks: ~46k nodes) blocks the event loop for more than 30 s, so the supervisor kills its own core. Combined with startup work this looks like "the app won't start".
Suggested: pause the watchdog while an indexing run is active (.indexing-run.json state), use exponential backoff, or add a /health/busy signal.
E. Incremental index persistence is O(N²)
deeptutor/services/rag/pipelines/llamaindex/storage.py::create_resumable_index calls _write_embedding_snapshot(...) — a full persist + fsync of the whole index — after every document. At ~46k nodes a 1,699-document rebuild took ~18 s/doc (hours) and wrote ~550 MB per checkpoint. The KB ended up with 127 index versions / 3.8 GB (PR #2356 adds cleanup, but not the write amplification).
Suggested: checkpoint every N documents or every T seconds instead of per document; avoid re-fsyncing unchanged files.
F. GitHub source auto-sync at startup triggers a full rebuild
services/github_source/sync_service.py uses SYNC_INTERVAL_HOURS = 24 and syncs stale sources when the service starts. Two GitHub sources are bound to AgentBooks; each sync publishes a new full version (~550 MB), making "startup" take minutes and often triggering (D). There is no setting to disable automatic sync while keeping the manual "sync now" action.
Suggested: expose a setting for automatic source sync (and a manual-only mode), and keep it off the startup critical path.
Impact
An in-place desktop upgrade can make the user's workspace appear lost, and the app can look completely broken (blank window, killed core) even while the backend is healthy.
Workarounds applied locally
- Converted the junction into a real folder (same-volume move); the workspace no longer contains junctions.
- Added
restore/show/focus/maximize → layout + 1px nudgeandsecond-instance → restore()in the desktop shell. - Raised
SYNC_INTERVAL_HOURSto 720 and pruned 127 index versions down to the active one (freed 2.19 GB).
Happy to provide full logs, the main.mjs diff, or test a patch.
Thanks for the detailed report — the file/line references match v1.7.3 exactly (main.mjs:262, the unguarded cp(runtimeHome, backup, { recursive: true }) in installUpdate() at main.mjs:312, and the second-instance handler at main.mjs:376), so this was easy to trace.
I'd like to claim the desktop shell part of this and send one PR against dev covering:
- A — make the pre-switch backup junction-aware, and stop treating a failed backup as fatal. Worth adding:
recoverInterruptedUpgrade()renamesruntimeHomeaway and then copies the backup back, so a backup that aborted after creating an emptydatadirectory is exactly how the workspace ends up looking lost. Backup and restore should be all-or-nothing for that reason, not just for the EPERM. - B — re-run
layout()onrestore/show/focus/maximize(and afterloadURL) so theWebContentsViewgets painted. - C —
if (window.isMinimized()) window.restore()beforeshow()/focus()in thesecond-instancehandler.
All three stay inside apps/desktop/src/main.mjs and can be exercised with the existing apps/desktop test setup.
On the rest of the report, so I don't duplicate work:
- D looks already covered by #2696 ("allow bounded recovery after desktop readiness misses" — 90 s grace from the first miss instead of three 10 s misses, plus diagnostics), so I'll leave the watchdog alone rather than open a competing PR.
- E and F are a different shape. E changes resume / atomic-swap semantics in
storage.py, an area #2356 and #2698 are actively working in, and F is a behaviour change that the contributing guide wants agreed on before code. I'd rather follow up separately than mix them into a desktop-shell PR.
Please let me know if that split works, or if you'd prefer A/B/C as three separate PRs. I can reproduce the junction/backup path and the minimized-window case on Windows 11 and will include before/after evidence with the PR.
Update: the desktop-shell fixes from this report are now up as #2726 ("fix(desktop): survive a junctioned data folder and a minimized window", targeting dev), and it is green in CI.
What it covers:
- A — the pre-switch backup no longer goes through
fs.cp; it walks the tree and follows reparse points, so a junctioneddatafolder no longer aborts the upgrade withEPERM. A failed backup is logged instead of aborting boot, and a partial copy is deleted so it can never be restored. - A, second half —
recoverInterruptedUpgrade()used to rename the whole workspace away before copying the backup back, which is how "sessions and knowledge bases are gone" can happen even when the backup itself was fine. Restore now writes over the existing tree, so a failed restore cannot leave a partial tree in place of the data, and a linkeddatafolder stays on its own drive instead of being replaced by a plain folder on the system drive. - B —
layout()now also runs onrestore,show,focusandmaximize, and once afterloadURL. - C —
second-instancerestores a minimized window before showing it.
Still open from the report, deliberately not in that PR: D looks covered by #2696 (90 s recovery grace instead of three 10 s misses), and E (per-document checkpoint write amplification) and F (no setting to keep manual "sync now" while disabling automatic source sync) are changes in other modules — E touches resume/atomic-swap semantics that #2356 and #2698 are working in, and F is a behaviour change that the contributing guide asks to agree on first. Happy to follow up on either, but they would be separate PRs.
Thanks again for the level of detail in the original report; the file and line references made this straightforward to pin down.