Skip to main content

Build Failures

TypeScript Errors During Build

Symptom: Build fails with TypeScript errors despite ignoreBuildErrors: true. Cause: While the Next.js config ignores build errors, Vercel may still fail if there are critical type issues.
This runs tsc --noEmit to check for type errors without emitting files.Fix any critical errors, especially:
  • Missing return types in API routes
  • Incorrect prop types in components
  • Invalid module imports
Verify your next.config.ts includes:
next.config.ts

Dependency Installation Failures

Symptom: npm install fails during Vercel deployment. Common causes:
Argument Cartographer requires Node.js 18+ due to Next.js 15 and modern ES modules.

Build Timeout on Vercel

Symptom: Build exceeds Vercel’s time limit (45 minutes on Hobby, configurable on Pro). Solutions:
  1. Optimize build process:
    package.json
  2. Check for slow dependencies:
  3. Upgrade to Vercel Pro if your project legitimately requires longer build times.

Authentication Issues

Firebase Authentication Not Initializing

Symptom: Users can’t sign in, or see “Firebase not initialized” errors.
1

Verify Environment Variables

Check all NEXT_PUBLIC_FIREBASE_* variables are set in Vercel:
Variables without NEXT_PUBLIC_ prefix are not accessible in client-side code.
2

Check Authorized Domains

In Firebase Console:
  1. Go to Authentication → Settings → Authorized domains
  2. Add your Vercel domain (e.g., your-app.vercel.app)
  3. Add custom domain if applicable
3

Verify Firebase Config Format

The config must match Firebase Console exactly:
src/firebase/config.ts

Permission Denied Errors

Symptom: Missing or insufficient permissions when accessing Firestore. The application implements strict security rules. The custom error handler provides detailed debugging:
Problem: User trying to access another user’s data.In the example above, auth.uid is user123 but the path contains user456.Solution: Ensure all Firestore paths use the authenticated user’s UID:
Problem: Document doesn’t have required userId field on creation.Security rules validate:
Solution: Include userId in all documents:
Problem: User is not signed in.The error will show "auth": null.Solution: Ensure user is authenticated before accessing Firestore:

API Integration Issues

Firecrawl API Failures

Symptom: Analysis fails with “Firecrawl API key not configured” or “Web Search failed”.
1

Verify API Key

Check the environment variable:
The application validates:
2

Check API Credits

Firecrawl has usage limits. Log in to Firecrawl Dashboard to check:
  • Remaining credits
  • Rate limit status
  • Recent API calls
3

Monitor Fallback Behavior

The application has built-in fallbacks when Firecrawl fails:
Check Vercel logs for these warnings to understand which fallback was triggered.

Twitter API Errors

Symptom: Social Pulse feature returns empty or fails with 401/403 errors.
Error: Twitter API request failed with status 401Solution:
  1. Verify token in Twitter Developer Portal
  2. Regenerate bearer token if expired
  3. Update TWITTER_BEARER_TOKEN in Vercel environment variables
  4. Redeploy application
Error: Twitter API request failed with status 429Twitter API v2 rate limits:
  • Basic tier: 500,000 tweets/month
  • Search endpoint: 180 requests per 15 minutes
Solution:
  • Wait for rate limit reset (check x-rate-limit-reset header)
  • Upgrade Twitter API tier
  • Implement caching for frequently searched topics
Twitter failures are non-fatal by design:
The analysis completes successfully with empty tweets array and no socialPulse summary.

Google Gemini API Issues

Symptom: Analysis fails with “AI failed to generate” errors.
1

Verify API Key

Get your key from Google AI Studio.
2

Check API Quotas

Gemini API has rate limits:
  • Free tier: 15 requests per minute
  • Paid tier: Higher limits based on plan
Monitor usage in Google Cloud Console.
3

Review Error Messages

Common errors:Safety filters triggered:
Solution: Rephrase input query to avoid triggering content filters.Token limit exceeded:
Solution: The app limits scraped content to 20,000 chars per source. If still failing, reduce number of sources.

Runtime Errors

JSON Parsing Failures

Symptom: “Failed to parse JSON from AI response” errors. The application uses JSON5 for lenient parsing, but AI responses sometimes have malformed JSON.
Check Vercel logs for:
This logs the actual AI response for debugging.
  1. AI returned text instead of JSON:
    • AI didn’t wrap response in ```json code block
    • Response is markdown or natural language
  2. Malformed JSON:
    • Trailing commas
    • Single quotes instead of double quotes
    • Unescaped special characters
  3. Response truncated:
    • AI hit token limit mid-response
    • Network error during streaming
The app attempts multiple parsing strategies:
If all fail, the error is thrown with the raw text for debugging.

Missing or Invalid Credibility Score

Symptom: Credibility score is 0, NaN, or outside 1-10 range. The application automatically fixes this:
If you still see invalid scores, the AI response may not include a credibilityScore field at all.

Null Source URIs

Symptom: Argument nodes have source: "null" instead of valid URLs. Automatic fix applied:
This ensures Zod validation passes for thesis nodes that don’t have external sources.

Performance Issues

See the dedicated Performance Troubleshooting guide for:
  • Slow analysis generation
  • High API costs
  • Firestore optimization
  • Caching strategies

Getting Help

1

Check Vercel Logs

Vercel Dashboard → Deployments → Select deployment → Function logsLook for:
  • Error stack traces
  • Console warnings
  • Performance metrics
2

Enable Debug Logging

The application includes extensive console logging:
These help trace the exact point of failure.
3

Test Locally

Reproduce the issue locally:
Check terminal output for detailed error messages not visible in production.
4

Review Firebase Rules

Test security rules in Firebase Console:Firestore Database → Rules → Rules Playground

Next Steps

API Errors

Detailed API error troubleshooting

Performance

Optimize application performance

Environment Variables

Review configuration requirements

Firebase Setup

Verify Firebase configuration