From cbca29cbcfd721e6d122336ebb045c09defb019d Mon Sep 17 00:00:00 2001 From: Marc Mintel Date: Tue, 27 Jan 2026 23:51:48 +0100 Subject: [PATCH] env --- .env | 4 ++++ instrumentation.ts | 11 +++++------ lib/services/logging/pino-logger-service.ts | 7 ++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 28be54ac..7c4b0e61 100644 --- a/.env +++ b/.env @@ -2,6 +2,10 @@ NODE_ENV=production NEXT_PUBLIC_BASE_URL=https://klz-cables.com LOG_LEVEL=info +PDF_DEBUG_EXCEL=0 +PDF_LOCALE= +PDF_MATCH= +PDF_LIMIT=0 # WooCommerce & WordPress WOOCOMMERCE_URL=https://klz-cables.com diff --git a/instrumentation.ts b/instrumentation.ts index f0cc2640..ae714898 100644 --- a/instrumentation.ts +++ b/instrumentation.ts @@ -1,5 +1,4 @@ import * as Sentry from '@sentry/nextjs'; -import { getServerAppServices } from '@/lib/services/create-services.server'; /** * Next.js will call this on boot for the active runtime. @@ -9,13 +8,13 @@ import { getServerAppServices } from '@/lib/services/create-services.server'; * - 'edge' when running in the Edge runtime (e.g. Middleware, Edge API Routes) */ export async function register() { - // Initialize server services on boot - if (process.env.NEXT_RUNTIME === 'nodejs') { - getServerAppServices(); - } - 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 { getServerAppServices } = await import('@/lib/services/create-services.server'); + getServerAppServices(); } if (process.env.NEXT_RUNTIME === 'edge') { diff --git a/lib/services/logging/pino-logger-service.ts b/lib/services/logging/pino-logger-service.ts index 360c449e..e4cb5132 100644 --- a/lib/services/logging/pino-logger-service.ts +++ b/lib/services/logging/pino-logger-service.ts @@ -9,11 +9,16 @@ export class PinoLoggerService implements LoggerService { if (parent) { this.logger = parent.child({ name }); } else { + // In Next.js, especially in the Edge runtime or during instrumentation, + // pino transports (which use worker threads) can cause issues. + // We disable transport in production and during instrumentation. + const useTransport = !config.isProduction && typeof window === 'undefined'; + this.logger = pino({ name: name || 'app', level: config.logging.level, transport: - !config.isProduction + useTransport ? { target: 'pino-pretty', options: {