Skip to content

Heartbeat activeHours timezone ignored — phase schedules based on UTC, not configured timezone #75487

Description

@raydoomed

Heartbeat activeHours ignores configured timezone — schedules based on UTC phase instead

Heartbeat 配置了 activeHours 时区为 Asia/Shanghai,但调度逻辑完全按 UTC phase 对齐,activeHours 的时区和窗口被忽略。

配置

"heartbeat": {
  "every": "4h",
  "activeHours": {
    "start": "08:00",
    "end": "23:00",
    "timezone": "Asia/Shanghai"
  }
}

问题

Phase 基于 UTC 计算,heartbeat 在以下 UTC 时刻触发:

  • 03:21 UTC → 11:21 Shanghai ✅ (在 activeHours 内)
  • 07:21 UTC → 15:21 Shanghai ✅ (在 activeHours 内)
  • 11:21 UTC → 19:21 Shanghai ✅ (在 activeHours 内)
  • 15:21 UTC → 23:21 Shanghai ❌ (quiet)
  • 19:21 UTC → 03:21 Shanghai ❌ (quiet)
  • 23:21 UTC → 07:21 Shanghai ❌ (quiet)

当 Gateway 在 quiet hours 时间窗口重启后,下一个 phase 触发时间可能仍然落在 quiet hours,导致心跳长时间不执行。

预期行为

activeHours 的 timezone 和窗口应该决定心跳应该在哪个本地时间触发,而不是"触发后决定是否执行"。

建议修复

方案 A:在计算下次触发时间时考虑 activeHours 窗口,从当前时刻开始找下一个落在 activeHours 内的 phase 对齐时间点

方案 B:允许用户配置 phase 对齐到本地时区的某个固定时间(如"每天 12:00 上海执行"),而不是 UTC 随机偏移

方案 C:添加启动时立即触发一次的功能(如果当前在 activeHours 内),避免静默等待

日志证据

2026-05-01T00:56:12.947+08:00 [heartbeat] started
(00:56 上海,属于 quiet hours,但调度器只记录"started"不说明下一次触发时间)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions