Docker stats subscription stays silent after collector stops; API restart restores events

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
docker, graphql, typescript

调研方向

Start by reading DockerStatsService.startStatsStream and SubscriptionTrackerService, which the issue identifies as the collector lifecycle and subscriber restart paths. Trace clean exit, signal, failure, subscriber reconnection, restart backoff, and intentional stop; check existing tests for these cases. Done means the collector recovers for active subscribers after it exits, while intentional stops leave no orphaned process.

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

描述

Environment

Unraid OS Version: 7.3.4; API 4.37.7+250d3663

Are you using a reverse proxy? No external reverse proxy. Reproduced directly on the server's IP through its built-in nginx /graphql endpoint.

Pre-submission Checklist

  • I have verified that my Unraid OS is up to date
  • I have tested this issue by accessing my server directly (not through a reverse proxy)
  • This is not an Unraid Connect related issue

Issue Description

The Docker statistics subscription stopped publishing any events on a running server with 12 running containers. HTTP inventory queries still succeeded, the WebSocket returned connection_ack, and subscribing to dockerContainerStats yielded no next/error/complete events. This left downstream Home Assistant CPU/memory aggregate sensors Unknown.

Restarting only the Unraid API service restored the subscription immediately, without restarting Docker, Home Assistant, or any container.

Steps to Reproduce

The original trigger for the collector stopping is not yet known. Once the stalled state exists:

  1. Verify docker inventory over GraphQL returns running containers.
  2. Open graphql-transport-ws, send connection_init with the API key, await connection_ack, then subscribe to:
subscription {
  dockerContainerStats {
    id
    cpuPercent
    memUsage
    memPercent
    netIO
    blockIO
  }
}
  1. Observe no events for a bounded 12–25 second probe; longer-lived HA subscriptions were also empty.
  2. On the host, docker stats --no-stream produces valid readings, but there is no long-lived docker stats --format ... --no-trunc process beneath the API process.
  3. Restart only unraid-api. Repeat step 2: valid events immediately arrive and IDs match inventory.

A deliberately invalid subscription received an immediate validation error, confirming the socket was processing operations rather than silently dropping client frames.

Expected Behavior

The stats collector should recover after its child process exits while subscribers remain active. New consumers should receive readings while Docker is healthy.

Actual Behavior

Existing and new consumers remain connected without stats. Reloading the HA integration alone did not restore the collector. API service restart restored events. All 12 containers retained their uptimes; array remained STARTED with no resync or disk errors.

Additional Context

In DockerStatsService.startStatsStream, statsProcess is treated as an active-process sentinel. Its completion handler clears that sentinel only when result.failed && !result.signal, and its catch branch skips err.killed. A clean exit or signal can therefore leave a non-null process handle after the collector is gone. SubscriptionTrackerService starts topics only on a 0→1 subscriber transition, so collector recovery with existing subscribers also needs consideration.

This lifecycle problem is a source-based hypothesis, not a confirmed original exit cause. Please cover clean exit, signal/kill, failure, subscriber retention/reconnection, restart backoff, and intentional stop without orphaning processes.

This differs from #2007: here no CPU/memory/I/O events arrive at all, rather than only I/O counters freezing.

主要语言
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 摘要。