Skip to content

fix(codegraph): make install + init robust on Windows (Access-denied, hung init)#2863

Merged
esengine merged 2 commits into
main-v2from
fix/codegraph-install-robust
Jun 3, 2026
Merged

fix(codegraph): make install + init robust on Windows (Access-denied, hung init)#2863
esengine merged 2 commits into
main-v2from
fix/codegraph-install-robust

Conversation

@esengine
Copy link
Copy Markdown
Owner

@esengine esengine commented Jun 3, 2026

Problem

On Windows the codegraph background install could fail at the final step with

codegraph: install failed (rename ...\.dl-xxx\codegraph-win32-x64 ...\v0.9.7: Access is denied)

os.Rename onto an existing v<ver> directory fails with Access denied on Windows, so once a partial/interrupted install left a stale v<ver> behind, every subsequent launch re-hit the same rename and never recovered — it just degraded to grep/glob and retried forever. A freshly-extracted .exe briefly locked by an AV scanner produces the same failure transiently.

Separately, EnsureInit ran codegraph init unbounded (ctx = app lifetime). A broken/partial launcher could hang it, and since the cmd → node tree isn't killed as a unit on Windows, that could wedge boot.

Fix

  • install.gopromote() clears a stale (incomplete) destination before the move and retries to ride out a transient AV lock. On a genuine permission failure the error now points at REASONIX_CACHE_DIR so users on a locked-down or read-only install location can relocate the cache.
  • codegraph.goEnsureInit now caps codegraph init with a timeout and tree-kills the process tree on cancel (reusing proc.KillTree), so a hung init can't hold up startup.

Tests

  • TestPromoteReplacesStalePartialDest — a non-empty stale dest (the exact Access-denied repro; plain os.Rename onto it fails on every OS) is replaced cleanly.

Notes

Builds on the stdio tree-kill fix already on main-v2 — together these make codegraph never able to wedge boot or loop on a failed install. codegraph remains optional: when it can't install, the agent degrades to grep/glob and the app stays fully usable.

reasonix added 2 commits June 3, 2026 00:17
os.Rename onto an existing v<ver> dir fails on Windows with Access denied,
so a partial cache from an interrupted install made every launch re-fail.
Clear a stale (incomplete) dest first and retry the move to ride out a
transient AV lock; on real permission failure point at REASONIX_CACHE_DIR.
EnsureInit ran init unbounded; a broken/partial launcher could hang it for
the whole session. Cap it with a timeout and tree-kill the cmd->node tree on
cancel (a plain Process.Kill leaves the node grandchild holding the pipes).
@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 3, 2026
@esengine esengine merged commit 9203288 into main-v2 Jun 3, 2026
6 checks passed
@esengine esengine deleted the fix/codegraph-install-robust branch June 3, 2026 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant