Work Intent: Fix state file watcher detachment by enabling polling on emhttp state files (#1788)

未关闭
#2,134 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
32/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
backend

调研方向

Do not start until a core developer removes the unapproved label. Once approved, read the file watcher setup in api/src/store/watch/state-watch.ts and the command client in api/src/core/utils/clients/emcmd.ts, then reproduce the stale var.ini state after an atomic replacement. Done means array state and parity check status stay current across replacements, with regression tests added.

由索引模型根据 Issue 内容生成。

描述

Overview

Resolves #1788 and eliminates desynchronization of array and parity check states in the GraphQL API.

In Unraid OS, emhttpd maintains live status files (such as /var/local/emhttp/var.ini) by writing to temporary files (*.ini.new) and atomically renaming them over the active state file. When unraid-api watches var.ini via inotify (usePolling: false), atomic file replacements detach the inotify watch from the unlinked inode. Once detached, the in-memory Redux store permanently ceases updating until the API daemon is restarted, causing array.state and array.parityCheckStatus queries to return stale snapshots indefinitely.

Technical Approach

  1. In api/src/store/watch/state-watch.ts, configure Chokidar to use path-based polling (usePolling: true) across emhttp state files (1s interval for dynamic files like var.ini, 10s interval for list collections like disks and shares).
  2. In api/src/core/utils/clients/emcmd.ts, trigger an immediate reload of StateFileKey.var upon successful command execution so callers reading state immediately receive the new state without polling latency.
  3. Add regression tests validating state reload consistency across atomic file replacements.

Scope

  • API
  • Plugin
  • Web UI
  • Build/Deploy Process
  • Documentation

Timeline & Impact

  • Estimated time needed: 1–2 days
  • Potential impacts: Eliminates stale array and parity states in the GraphQL API; minimal CPU overhead (single-path stat polling at 1s interval).

Pre-submission Checklist

  • I have searched for similar work/issues
  • I understand this needs approval before starting
  • I am willing to make adjustments based on feedback
主要语言
TypeScript
星标
123
派生
25
平均合并
2 天 16 小时
30 天内合并 PR
9

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

unraid/api 的其他 Issue

查看 unraid/api 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。