[Bug]: /healthz with a query string triggers a heartbeat
维护者通常 1 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Read the heartbeat middleware in src/node/routes/index.ts and the unit-test setup mentioned in the report. Reproduce with /healthz?probe=1 followed by /healthz and check the heartbeat state. Done means the query-string health check does not trigger a heartbeat, and a test covers that behavior; the author says they are opening a PR with a fix and test.
由索引模型根据 Issue 内容生成。
描述
Is there an existing issue for this?
- I have searched the existing issues
OS/Web Information
- Web Browser: not needed, reproduced with the unit tests
- Local OS: Windows 11
- Remote OS: Windows 11
- Remote Architecture: x64
code-server --version:mainat dda09f2
Steps to Reproduce
- Start code-server, for example with
--auth none. - Request
/healthzwith any query string, for exampleGET /healthz?probe=1, as a monitor or load balancer that adds a cache-busting or probe parameter does. - Request
/healthzagain.
Expected
As the FAQ says, /healthz reports the status "without triggering a heartbeat", so an idle instance stays expired with lastHeartbeat: 0, the heartbeat file is not touched, and --idle-timeout-seconds still shuts it down.
Actual
Three requests in a row against an idle instance on main (dda09f2), from the unit test setup with --auth=none:
GET /healthz -> {"status":"expired","lastHeartbeat":0}
GET /healthz?probe=1 -> {"status":"alive","lastHeartbeat":1794543674997}
GET /healthz -> {"status":"alive","lastHeartbeat":1794543674997}
The middleware in src/node/routes/index.ts that skips the heartbeat for health checks matches the path against req.url, which includes the query string:
if (!/^\/healthz\/?$/.test(req.url)) {
heart.beat()
}
So /healthz?probe=1 is treated as activity: it sets lastHeartbeat, touches the heartbeat file and cancels the idle shutdown timer. A monitor that polls with a query string more often than --idle-timeout-seconds keeps the instance from ever shutting down, and anything that watches the heartbeat file sees it as in use.
Logs
Not applicable.
Screenshot/Video
No response
Does this bug reproduce in native VS Code?
This cannot be tested in native VS Code
Does this bug reproduce in VS Code web?
This cannot be tested in VS Code web
Does this bug reproduce in GitHub Codespaces?
This cannot be tested in GitHub Codespaces
Are you accessing code-server over a secure context?
- I am using a secure context.
Notes
The fix is to match req.path, which has no query string. I am opening a PR with the fix and a test.
AI-assisted: found and reproduced with an AI coding agent; the check above was run locally.
- 主要语言
- TypeScript
- 星标
- 79.9k
- 派生
- 6.9k
- 平均合并
- 20 小时 21 分钟
- 30 天内合并 PR
- 51
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
coder/code-server 的其他 Issue
-
Error not true未关闭
难度 3/5 1-2 天 新手友好度 45/100
coder/code-server#8148 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 51/100
coder/code-server#8145 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 15/100
coder/code-server#8142 · 1 条评论 ·
维护者通常 1 天内回复
-
[Bug]: --proxy-domain does not proxy when the host includes a port可能已有人在做 @adityajai119 于 10 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
coder/code-server#8128 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement
难度 3/5 1-2 天 新手友好度 57/100
coder/code-server#8113 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 coder/code-server 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
vercel-labs/ui#1066 ·
维护者通常 1 天内回复
-
fix(factory-cockpit): display active agent/actor name instead of verbose step name in run card badge未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
ranxianglei/billion-context#7597 ·
维护者通常 1 天内回复
-
documentation target:powerpoint
难度 1/5 1 小时以内 新手友好度 76/100
tomast1337/PdfLapas#602 ·
维护者通常 1 天内回复
-
kubernetes-ingestor: fetchCRDMapping() runs even when crossplane.enabled is false, logging a 403 ERROR every run可能已有人在做 @kc9ddi 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
TeraSky-OSS/backstage-plugins#228 ·