chore(observability): port Sentry and memory optimizations from klz-2026
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 56s
Build & Deploy / 🧪 QA (push) Successful in 2m9s
CI - Lint, Typecheck & Test / quality-assurance (pull_request) Failing after 3m30s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 56s
Build & Deploy / 🧪 QA (push) Successful in 2m9s
CI - Lint, Typecheck & Test / quality-assurance (pull_request) Failing after 3m30s
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🏗️ Build (push) Has been cancelled
This commit is contained in:
5
instrumentation-client.ts
Normal file
5
instrumentation-client.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// Sentry initialization move to GlitchtipErrorReportingService to allow lazy-loading
|
||||
// for PageSpeed 100 optimizations. This file is now empty to prevent the SDK
|
||||
// from being included in the initial JS bundle.
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
|
||||
25
instrumentation.ts
Normal file
25
instrumentation.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
|
||||
/**
|
||||
* Next.js will call this on boot for the active runtime.
|
||||
*/
|
||||
export async function register() {
|
||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||
await import('./sentry.server.config');
|
||||
|
||||
// Initialize server services on boot
|
||||
// We do this AFTER Sentry to ensure errors during service init are caught
|
||||
const { getConfig } = await import('@/lib/config');
|
||||
getConfig(); // Trigger validation
|
||||
|
||||
const { getServerAppServices } = await import('@/lib/services/create-services.server');
|
||||
getServerAppServices();
|
||||
}
|
||||
|
||||
if (process.env.NEXT_RUNTIME === 'edge') {
|
||||
await import('./sentry.edge.config');
|
||||
}
|
||||
}
|
||||
|
||||
// Capture errors from Server Components, middleware and route handlers.
|
||||
export const onRequestError = Sentry.captureRequestError;
|
||||
@@ -9,8 +9,8 @@ const isProd = process.env.NODE_ENV === 'production';
|
||||
const nextConfig = {
|
||||
transpilePackages: ['react-image-crop', '@react-three/fiber'],
|
||||
onDemandEntries: {
|
||||
// Keep compiled pages/routes in memory for 5 minutes (reduced from 25m to prevent OOM)
|
||||
maxInactiveAge: 5 * 60 * 1000,
|
||||
// Keep compiled pages/routes in memory for 1 minute (optimized for memory usage)
|
||||
maxInactiveAge: 60 * 1000,
|
||||
// Keep up to 2 pages in the dev buffer (reduced from 10 to prevent OOM)
|
||||
pagesBufferLength: 2,
|
||||
},
|
||||
@@ -507,6 +507,10 @@ const nextConfig = {
|
||||
source: '/en/agbs',
|
||||
destination: '/en/terms',
|
||||
},
|
||||
{
|
||||
source: '/errors/:path*',
|
||||
destination: `${glitchtipDomain}/:path*`,
|
||||
},
|
||||
],
|
||||
afterFiles: [],
|
||||
fallback: [],
|
||||
|
||||
15
sentry.edge.config.ts
Normal file
15
sentry.edge.config.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
|
||||
const dsn = process.env.SENTRY_DSN;
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
|
||||
Sentry.init({
|
||||
dsn,
|
||||
enabled: isProd && Boolean(dsn),
|
||||
|
||||
// Adjust this value in production, or use tracesSampler for greater control
|
||||
tracesSampleRate: 1,
|
||||
|
||||
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
||||
debug: false,
|
||||
});
|
||||
15
sentry.server.config.ts
Normal file
15
sentry.server.config.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
|
||||
const dsn = process.env.SENTRY_DSN;
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
|
||||
Sentry.init({
|
||||
dsn,
|
||||
enabled: isProd && Boolean(dsn),
|
||||
|
||||
// Adjust this value in production, or use tracesSampler for greater control
|
||||
tracesSampleRate: 1,
|
||||
|
||||
// Setting this option to true will print useful information to the console while you're setting up Sentry.
|
||||
debug: false,
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
export function register() {
|
||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||
console.log('[Instrumentation] Server-side registration active');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user