Compare commits

2 Commits

Author SHA1 Message Date
Marco Gallegos
02b933d893 Fix JSON parsing error in Google Calendar initialization
- Add try-catch for JSON.parse with better error handling
- Validate credentials structure before use
- Add detailed error logging for debugging
- Prevent build failure from invalid GOOGLE_SERVICE_ACCOUNT_JSON

Fixes SyntaxError during Next.js build process
2026-01-18 09:54:51 -06:00
Marco Gallegos
439cc80546 Fix Docker build memory issue by increasing Node.js heap size
- Increase Node.js max old space size to 4GB for build
- Resolve 'JavaScript heap out of memory' error during Docker build
- Enable successful Coolify deployment
2026-01-18 09:46:25 -06:00
2 changed files with 18 additions and 3 deletions

View File

@@ -22,8 +22,11 @@ ENV NODE_ENV production
ENV NEXT_PUBLIC_SUPABASE_URL=https://placeholder.supabase.co ENV NEXT_PUBLIC_SUPABASE_URL=https://placeholder.supabase.co
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=placeholder-anon-key ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=placeholder-anon-key
ENV SUPABASE_SERVICE_ROLE_KEY=placeholder-service-role-key ENV SUPABASE_SERVICE_ROLE_KEY=placeholder-service-role-key
ENV STRIPE_SECRET_KEY=sk_test_placeholder_key ENV STRIPE_SECRET_KEY=<REDACTED>
ENV RESEND_API_KEY=re_placeholder_key ENV RESEND_API_KEY=<REDACTED>
# Aumentar memoria disponible para Node.js durante el build
ENV NODE_OPTIONS=--max-old-space-size=4096
# Build optimizado # Build optimizado
RUN npm run build RUN npm run build

View File

@@ -46,7 +46,19 @@ class GoogleCalendarService {
return; return;
} }
const credentials = JSON.parse(serviceAccountJson) as ServiceAccountConfig; let credentials: ServiceAccountConfig;
try {
credentials = JSON.parse(serviceAccountJson) as ServiceAccountConfig;
} catch (jsonError) {
console.error('GoogleCalendar: Failed to parse GOOGLE_SERVICE_ACCOUNT_JSON', jsonError);
console.error('GoogleCalendar: Service account JSON value:', serviceAccountJson);
throw new Error('Invalid GOOGLE_SERVICE_ACCOUNT_JSON format. Please check environment variable.');
}
if (!credentials.type || !credentials.project_id || !credentials.private_key) {
throw new Error('Invalid GOOGLE_SERVICE_ACCOUNT_JSON: Missing required fields');
}
const auth = new google.auth.GoogleAuth({ const auth = new google.auth.GoogleAuth({
credentials, credentials,