Skip to content

fix(platform): add getLogsDir fallback to inline platform services#1980

Merged
piorpua merged 1 commit intomainfrom
fix/sentry-ELECTRON-GW
Mar 31, 2026
Merged

fix(platform): add getLogsDir fallback to inline platform services#1980
piorpua merged 1 commit intomainfrom
fix/sentry-ELECTRON-GW

Conversation

@kaizhou-lab
Copy link
Copy Markdown
Collaborator

Summary

  • Add try-catch fallback for app.getPath('logs') in the inline auto-registered platform services (src/common/platform/index.ts), matching the existing fallback in ElectronPlatformServices
  • The inline path is used when code runs before registerPlatformServices() is called; without the fallback, app.getPath('logs') throws on some systems, causing "Failed to get 'logs' path" errors through the adapter bridge IPC
  • Add regression test to verify the inline implementation contains the required try-catch pattern

Fixes Sentry issue ELECTRON-GW (2 events).

Test plan

  • New test inlinePlatformServices.test.ts verifies the try-catch pattern exists in index.ts
  • All existing platform tests pass (21/21)
  • tsc --noEmit passes
  • bun run lint — 0 errors

The inline auto-registered platform services in index.ts were missing
the try-catch fallback for app.getPath('logs') that was added to
ElectronPlatformServices in PR #1967. When code runs before
registerPlatformServices() is called, the inline path throws on systems
where app.getPath('logs') fails, causing 'Failed to get logs path'
errors through the adapter bridge IPC.
@piorpua piorpua added the bot:reviewing Review in progress (mutex) label Mar 31, 2026
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 31, 2026

Code Review:fix(platform): add getLogsDir fallback to inline platform services (#1980)

变更概述

本 PR 为 src/common/platform/index.ts 中的 inline 自动注册平台服务添加了 getLogsDir 的 try-catch 降级逻辑,与 ElectronPlatformServices 中已有的相同模式保持一致。当 app.getPath('logs') 在某些系统上抛出异常时,回退到 path.join(app.getPath('userData'), 'logs')。同时新增回归测试文件验证该模式存在。


方案评估

结论:✅ 方案合理

修复直接针对 Sentry 上报的 ELECTRON-GW 错误,方案与 ElectronPlatformServices 已有的降级模式完全一致,保持了两处实现的同步性。新增的 path import 仅在降级路径使用,不影响正常路径。测试策略合理——由于 inline 实现依赖 require('electron') 无法被 Vitest mock,采用源码模式匹配 + 逻辑复现的方式验证,兼顾了实用性和可维护性。


问题清单

✅ 未发现明显问题,代码质量良好。


汇总

# 严重级别 文件 问题
无问题

结论

批准合并 — 改动精确、与现有模式一致、有回归测试覆盖,无阻塞性问题。


本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。

CONCLUSION: APPROVED
IS_CRITICAL_PATH: false
PR_NUMBER: 1980

@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 31, 2026

✅ 已自动 review,无阻塞性问题,正在触发自动合并。

@piorpua piorpua merged commit e7a142c into main Mar 31, 2026
17 checks passed
@piorpua piorpua deleted the fix/sentry-ELECTRON-GW branch March 31, 2026 10:54
@piorpua piorpua added bot:done Auto-merged by bot and removed bot:reviewing Review in progress (mutex) labels Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:done Auto-merged by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants