Skip to content

Commit 67163dd

Browse files
d-csclaude
andcommitted
fix(webapp): don't let an unreachable run-ops shard crash webapp startup
The run-ops client factory eagerly $connects for warm-up, but only caught the rejection under NODE_ENV=test — outside test an unreachable shard/run-ops DB at boot surfaced as an unhandled promise rejection. Always catch and log instead; Prisma reconnects lazily on first query, so one unreachable shard must not take down startup. Scoped to the run-ops factory only; the control-plane/legacy builders are unchanged, so the RUN_OPS_SHARDS-unset path stays byte-identical. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 908fcb5 commit 67163dd

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

apps/webapp/app/db.server.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,12 +1124,13 @@ function buildRunOpsClient({
11241124

11251125
client.$on("query", (log) => queryPerformanceMonitor.onQuery(role, log));
11261126

1127-
const connectPromise = client.$connect();
1128-
if (env.NODE_ENV === "test") {
1129-
connectPromise.catch((error) => {
1130-
logger.warn(`Failed to eagerly connect run-ops prisma client (${role})`, { error });
1131-
});
1132-
}
1127+
// Eager connect is a warm-up only — Prisma reconnects lazily on first query. ALWAYS catch the
1128+
// rejection (not just under NODE_ENV=test), so a shard/run-ops DB that is unreachable at boot
1129+
// logs a warning instead of surfacing as an unhandled promise rejection. One unreachable shard
1130+
// must not take down webapp startup.
1131+
client.$connect().catch((error) => {
1132+
logger.warn(`Failed to eagerly connect run-ops prisma client (${role})`, { error });
1133+
});
11331134

11341135
console.log(`🔌 ${connectedLabel}`);
11351136

0 commit comments

Comments
 (0)