[Bug]: /healthz with a query string triggers a heartbeat

Abierto
#8,126 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@adityajai119 ya está trabajando en esto.

Desde el 13/11/2026.

  • #8127 de @adityajai119 — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
backend, testing

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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: main at dda09f2
Steps to Reproduce
  1. Start code-server, for example with --auth none.
  2. Request /healthz with any query string, for example GET /healthz?probe=1, as a monitor or load balancer that adds a cache-busting or probe parameter does.
  3. Request /healthz again.
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.

Lenguaje dominante
TypeScript
Estrellas
79.9k
Forks
6.9k
Merge medio
20 h 21 min
PR fusionados (30 d)
51

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de coder/code-server

Todos los issues de coder/code-server

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.