fix(cron,desktop): pass gateway loop to run_one_job for Matrix cron delivery; discover UGit git binary (#61495, #61494) - #61503
Conversation
…ivery uses live-adapter path (NousResearch#61495) Manual cron runs triggered from a Matrix gateway session (cronjob action='run') failed during delivery with: Timeout context manager should be used inside a task Root cause: _execute_job_now called run_one_job(job) without adapters or loop, so _deliver_result fell back to the standalone asyncio.run() path. That path created a new event loop, but _send_matrix_via_adapter re-acquired the live Matrix adapter (whose internal aiohttp session was bound to the gateway's original loop) from the new loop, causing the cross-loop RuntimeError. Fix: 1. _execute_job_now now resolves the gateway runner's adapters and _gateway_loop and passes them to run_one_job, so the delivery uses the live-adapter path (safe_schedule_threadsafe on the correct gateway loop). 2. _send_matrix_via_adapter adds a defense-in-depth RuntimeError catch around the live-adapter branch, falling back to the ephemeral adapter when the live adapter is unusable from the current event loop.
…ry scan (NousResearch#61494) UGit installs a portable Git under a versioned app-* subdirectory of %LOCALAPPDATA%\UGit. The standard resolveGitBinary() candidate list did not include this path, so check-for-updates and other git operations failed silently on systems that use UGit instead of Git-for-Windows. Fix: enumerate %LOCALAPPDATA%\UGit\app-*\resources\app\git\cmd\git.exe dynamically rather than hard-coding a single version, so the discovery survives UGit updates that change the app-* suffix.
Competing fix for #61495 with #61502, via a different mechanism: this PR fixes the caller ( |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment
Overview
- Small change: passes gateway loop to run_one_job for Matrix cron delivery
- Also discovers UGit git binary
Looks Good
- Clean, focused fix
- No security concerns
Reviewed by Hermes Agent
|
bootstrap-installer.log 找到了。第 9466 行就是 subprocess.run(["git", ...])——你的系统 PATH 里没有 git。 |
|
Thanks for tracing both failures to their concrete resolution paths. Current main still calls Problems
Suggested changes
This is an automated hermes-sweeper review. |
Cluster for #61495 (Matrix manual cron delivery cross-loop failure): #61503 (this) fixes the caller (passes the gateway runner's adapters + loop into run_one_job) and also bundles an unrelated UGit git-binary discovery fix for #61494; #61502 fixes the callee (Matrix adapter swaps ClientTimeout for asyncio.wait_for); #62956 fixes the generic cron dispatch (loop-mismatch guard + standalone-sender fallback). All three are competing approaches to the same delivery bug — related, not duplicates. Maintainer picks the canonical fix. |
|
Stale — no merge activity for 4-6 days. Can resubmit if still needed. |
Fix #61495 — Matrix cron delivery timeout context issue
Manual cron runs triggered from a Matrix gateway session (
cronjob action='run') failed during delivery with:The job itself completed (
last_status: ok); only the final Matrix delivery failed.Root Cause
_execute_job_nowcalledrun_one_job(job)withoutadaptersorloop, so_deliver_resultfell back to the standaloneasyncio.run()path. That path created a new event loop, but_send_matrix_via_adapterre-acquired the live Matrix adapter (whose internal aiohttp session was bound to the gateway's original loop) from the new loop, causing the cross-loopRuntimeError.Changes
_execute_job_nownow resolves_gateway_runner_ref()to obtain the gateway runner'sadaptersand_gateway_loop, then passes them torun_one_job. The delivery then uses the live-adapter path (safe_schedule_threadsafeon the correct gateway loop) instead of creating a new loop._send_matrix_via_adapteradds a defense-in-depthRuntimeErrorcatch around the live-adapter branch, falling back gracefully to the ephemeral (E2EE-capable) adapter when the live adapter is unusable from the current event loop.Fix #61494 — Desktop git binary not found with UGit
Hermes Desktop's check-for-updates and other git operations fail on Windows systems that use UGit instead of standard Git-for-Windows.
Root Cause
UGit installs a portable Git under a versioned app-* subdirectory:
%LOCALAPPDATA%\\UGit\\app-*\\resources\\app\\git\\cmd\\git.exeThe version suffix changes with each UGit update, so the path cannot be hard-coded. The existing
findOnPath('git')fallback should catch UGit when its directory is on PATH, but Electron processes launched from Explorer inherit the login-time environment block, which may not include PATH entries added later by UGit's installer.Changes
resolveGitBinary()now enumerates%LOCALAPPDATA%\\UGit\\forapp-*directories and adds each discoveredresources/app/git/cmd/git.exeto the candidate list. The existingfileExistscheck selects the first valid binary, so stale/removed versions are skipped automatically.Closes #61495
Closes #61494