fix: empty MCPD_BACKUP_REPO crashes mcpd on healthz with ERR_HTTP_HEADERS_SENT

Two bugs: (1) empty string env var treated as enabled (use || instead of ??),
(2) health routes missing return reply causing double-send with onSend hook.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michal
2026-03-08 01:29:45 +00:00
parent 98f3a3eda0
commit af9f7458fc
2 changed files with 3 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ export function registerHealthRoutes(app: FastifyInstance, deps: HealthDeps): vo
const status = dbOk ? 'healthy' : 'degraded';
const statusCode = dbOk ? 200 : 503;
reply.code(statusCode).send({
return reply.code(statusCode).send({
status,
version: APP_VERSION,
uptime: process.uptime(),
@@ -25,6 +25,6 @@ export function registerHealthRoutes(app: FastifyInstance, deps: HealthDeps): vo
// Simple liveness probe
app.get('/healthz', async (_request, reply) => {
reply.code(200).send({ status: 'ok' });
return reply.code(200).send({ status: 'ok' });
});
}

View File

@@ -75,7 +75,7 @@ export class GitBackupService {
private readonly prisma: PrismaClient,
repoUrl?: string,
) {
this.repoUrl = repoUrl ?? process.env.MCPD_BACKUP_REPO ?? null;
this.repoUrl = repoUrl || process.env.MCPD_BACKUP_REPO || null;
}
get enabled(): boolean {