Files
Nexus/apps/web/src/instrumentation.ts
T
Hartmut 485e220c49 fix(api,web): env startup validation, QueryClient defaults, warn on missing REDIS_URL
- Throw at startup in production if REDIS_URL/DATABASE_URL/NEXTAUTH_SECRET missing
- Warn in development when REDIS_URL falls back to localhost
- QueryClient: add gcTime, disable refetchOnWindowFocus, skip retry on 4xx

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-09 16:42:34 +02:00

27 lines
954 B
TypeScript

export async function register() {
// Validate required env vars at startup — throws immediately in production
// if REDIS_URL, DATABASE_URL, or NEXTAUTH_SECRET are missing.
if (process.env.NEXT_RUNTIME === "nodejs") {
const { assertProductionEnv } = await import("@capakraken/api");
assertProductionEnv();
}
// Only load Sentry in production — the worker.js crash in dev mode
// (vendor-chunks/lib/worker.js MODULE_NOT_FOUND) makes the dev server unstable
if (process.env.NODE_ENV === "production") {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("../sentry.server.config");
}
if (process.env.NEXT_RUNTIME === "edge") {
await import("../sentry.edge.config");
}
}
}
export async function onRequestError(...args: unknown[]) {
if (process.env.NODE_ENV === "production") {
const Sentry = await import("@sentry/nextjs");
(Sentry.captureRequestError as Function)(...args);
}
}