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:
@@ -12,7 +12,7 @@ export function registerHealthRoutes(app: FastifyInstance, deps: HealthDeps): vo
|
|||||||
const status = dbOk ? 'healthy' : 'degraded';
|
const status = dbOk ? 'healthy' : 'degraded';
|
||||||
const statusCode = dbOk ? 200 : 503;
|
const statusCode = dbOk ? 200 : 503;
|
||||||
|
|
||||||
reply.code(statusCode).send({
|
return reply.code(statusCode).send({
|
||||||
status,
|
status,
|
||||||
version: APP_VERSION,
|
version: APP_VERSION,
|
||||||
uptime: process.uptime(),
|
uptime: process.uptime(),
|
||||||
@@ -25,6 +25,6 @@ export function registerHealthRoutes(app: FastifyInstance, deps: HealthDeps): vo
|
|||||||
|
|
||||||
// Simple liveness probe
|
// Simple liveness probe
|
||||||
app.get('/healthz', async (_request, reply) => {
|
app.get('/healthz', async (_request, reply) => {
|
||||||
reply.code(200).send({ status: 'ok' });
|
return reply.code(200).send({ status: 'ok' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export class GitBackupService {
|
|||||||
private readonly prisma: PrismaClient,
|
private readonly prisma: PrismaClient,
|
||||||
repoUrl?: string,
|
repoUrl?: string,
|
||||||
) {
|
) {
|
||||||
this.repoUrl = repoUrl ?? process.env.MCPD_BACKUP_REPO ?? null;
|
this.repoUrl = repoUrl || process.env.MCPD_BACKUP_REPO || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get enabled(): boolean {
|
get enabled(): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user