Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const register = async (
const common: express.RequestHandler = (req, _, next) => {
// /healthz|/healthz/ needs to be excluded otherwise health checks will make
// it look like code-server is always in use.
if (!/^\/healthz\/?$/.test(req.url)) {
if (!/^\/healthz\/?$/.test(req.path)) {
// NOTE@jsjoeio - intentionally not awaiting the .beat() call here because
// we don't want to slow down the request.
heart.beat()
Expand Down
8 changes: 8 additions & 0 deletions test/unit/node/routes/health.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ describe("health", () => {
expect(json).toStrictEqual({ lastHeartbeat: 0, status: "expired" })
})

it("/healthz with a query string", async () => {
codeServer = await integration.setup(["--auth=none"], "")
const resp = await codeServer.fetch("/healthz", undefined, { probe: "1" })
expect(resp.status).toBe(200)
const json = await resp.json()
expect(json).toStrictEqual({ lastHeartbeat: 0, status: "expired" })
})

it("/healthz (websocket)", async () => {
codeServer = await integration.setup(["--auth=none"], "")
const ws = codeServer.ws("/healthz")
Expand Down
Loading