🟡 [M4] watcher 后端错误被静默丢弃 #14

Closed
opened 2026-06-03 13:53:56 +08:00 by dailz · 1 comment
Owner

文件: core/watcher/file_watcher.rs:57-60
分类: 错误处理

问题: watcher backend 错误(I/O 错误、rescan 错误等)被 Err(_) => return 静默忽略,应用不知道监控已失效。

let event = match res {
    Ok(e) => e,
    Err(_) => return,  // ← 静默丢弃!
};

建议修复: 添加 FileEvent::WatcherError(String) 或暴露错误通道;至少日志记录并触发重新同步。

**文件**: `core/watcher/file_watcher.rs:57-60` **分类**: 错误处理 **问题**: watcher backend 错误(I/O 错误、rescan 错误等)被 `Err(_) => return` 静默忽略,应用不知道监控已失效。 ```rust let event = match res { Ok(e) => e, Err(_) => return, // ← 静默丢弃! }; ``` **建议修复**: 添加 `FileEvent::WatcherError(String)` 或暴露错误通道;至少日志记录并触发重新同步。
dailz added the area/concurrencyseverity/mediumbug labels 2026-06-03 13:53:56 +08:00
Author
Owner

修复提交: 7852e92

修复内容:

  • FileEvent enum 新增 WatcherError { message: String } 变体,用于传递 notify 后端错误
  • 回调中 Err(_) => return 替换为 try_send(FileEvent::WatcherError),错误通过现有 bounded channel 转发给消费者
  • 消费端 poll_file_watcher 新增 WatcherError match 分支,瞬态错误不中断 UI
  • 补充 WatcherError equality 测试

设计决策:

  • 使用 { message: String } 命名载荷,与其他变体风格一致,便于未来扩展
  • 使用 try_send 而非 send,避免在 notify 后端线程上阻塞
  • 消费端暂为 no-op(项目无 log crate 依赖),后续可加日志输出
  • 不销毁 watcher — notify 后续事件可能恢复
**修复提交**: 7852e92 **修复内容**: - `FileEvent` enum 新增 `WatcherError { message: String }` 变体,用于传递 notify 后端错误 - 回调中 `Err(_) => return` 替换为 `try_send(FileEvent::WatcherError)`,错误通过现有 bounded channel 转发给消费者 - 消费端 `poll_file_watcher` 新增 `WatcherError` match 分支,瞬态错误不中断 UI - 补充 `WatcherError` equality 测试 **设计决策**: - 使用 `{ message: String }` 命名载荷,与其他变体风格一致,便于未来扩展 - 使用 `try_send` 而非 `send`,避免在 notify 后端线程上阻塞 - 消费端暂为 no-op(项目无 log crate 依赖),后续可加日志输出 - 不销毁 watcher — notify 后续事件可能恢复
dailz closed this issue 2026-06-09 11:27:45 +08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dailz/logViewer#14