fix(gemini): ensure workspace dir exists before initialization#1784
fix(gemini): ensure workspace dir exists before initialization#1784
Conversation
…ation
The external library aioncli-core calls `await fs.realpath(workspace)` in
loadServerHierarchicalMemory without try-catch. When the temp workspace
directory (gemini-temp-*) is removed between creation and worker process
initialization (e.g. by OS cleanup or antivirus on Windows), this causes
an unhandled ENOENT promise rejection.
Add a defensive `fs.promises.mkdir(path, { recursive: true })` at the
start of GeminiAgent.initialize() to recreate the directory if missing.
The call is idempotent and preserves existing directory contents.
Fixes ELECTRON-6W (949 occurrences)
c7f8bf8 to
47cfc34
Compare
CI 检查未通过以下 job 在本次自动化 review 时未通过,请修复:
本次自动化 review 暂缓,待 CI 全部通过后将重新处理。 |
Code Review:fix(gemini): ensure workspace dir exists before initialization (#1784)变更概述本 PR 修复了 Sentry 高频问题 ELECTRON-6W(949 次),根因是 方案评估结论:✅ 方案合理 修复直接命中根因:在第三方代码的 问题清单🔵 LOW — 测试验证的是 Node.js fs 行为而非 GeminiAgent 的调用文件: 问题说明:4 个测试用例均直接调用 Node.js 理想的补充测试应 mock 汇总
结论✅ 批准合并 — 修复精准、幂等,无阻塞性问题。 本报告由本地 |
|
✅ 已自动 review,无阻塞性问题,正在触发自动合并。 |
Summary
ENOENT: no such file or directory, realpath 'gemini-temp-*'fs.promises.mkdir(path, { recursive: true })at the start ofGeminiAgent.initialize()to ensure the workspace directory exists beforeloadCliConfigcallsloadServerHierarchicalMemory, which internally doesawait fs.realpath(workspace)without try-catchCloses #1839
Test plan
tests/unit/geminiWorkspaceRecovery.test.tswith 4 tests covering:fs.realpathfails with ENOENT on deleted directory (reproduces the bug)mkdirwithrecursive:truerecreates a deleted directoryfs.realpathsucceeds aftermkdirrecreation (verifies the fix)mkdiris idempotent on existing directories (no side effects)