Skip to content

Commit fef11ba

Browse files
committed
Healthcheck moved earlier
1 parent d9c04ac commit fef11ba

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

apps/webapp/app/routes/healthcheck.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ import { rbac } from "~/services/rbac.server";
55

66
export const loader: LoaderFunction = async ({ request }) => {
77
try {
8+
// Resolve the lazy plugin controller so plugin-load failures surface
9+
// during readiness probes. With REQUIRE_PLUGINS=1, a failed plugin
10+
// load throws here and the rollout's readiness probe fails. The
11+
// fallback path doesn't touch the DB, so this runs even when
12+
// HEALTHCHECK_DATABASE_DISABLED=1 — REQUIRE_PLUGINS protection must
13+
// not be silently bypassed by the DB-disabled flag.
14+
await rbac.isUsingPlugin();
15+
816
if (env.HEALTHCHECK_DATABASE_DISABLED === "1") {
917
return new Response("OK");
1018
}
1119

1220
await prisma.$queryRaw`SELECT 1`;
1321

14-
// Resolve the lazy plugin controller so plugin-load failures surface
15-
// during readiness probes. With REQUIRE_PLUGINS=1, a failed plugin
16-
// load throws here and the rollout's readiness probe fails. Without
17-
// REQUIRE_PLUGINS, the fallback resolves cleanly and this is a noop.
18-
await rbac.isUsingPlugin();
19-
2022
return new Response("OK");
2123
} catch (error: unknown) {
2224
console.log("healthcheck ❌", { error });

apps/webapp/server.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,18 @@ if (ENABLE_CLUSTER && cluster.isPrimary) {
197197
})
198198
);
199199
} else {
200-
// we need to do the health check here at /healthcheck
201-
app.get("/healthcheck", (req, res) => {
202-
res.status(200).send("OK");
203-
});
200+
// we need to do the health check here at /healthcheck — forward
201+
// to the Remix handler so the loader's readiness checks (DB ping,
202+
// REQUIRE_PLUGINS-gated plugin load) run in this mode too. A
203+
// static 200 here would silently mask a failed plugin load.
204+
app.get(
205+
"/healthcheck",
206+
// @ts-ignore
207+
createRequestHandler({
208+
build,
209+
mode: MODE,
210+
})
211+
);
204212
}
205213

206214
const server = app.listen(port, () => {

0 commit comments

Comments
 (0)