Common issues and solutions when working with SaaSPilot.
# Solution: Generate Prisma client
npx prisma generate- Check DATABASE_URL in
.env.local - Verify MongoDB is running
- Check network/firewall settings
- Test connection:
npx prisma db pull
# Reset database (WARNING: deletes all data)
npx prisma migrate reset
# Or push schema without migration
npx prisma db push- Email already exists in database
- Use
findFirstto check before creating - Handle P2002 error code in catch block
- Check NEXTAUTH_SECRET is set
- Verify NEXTAUTH_URL matches your domain
- Clear browser cookies
- Check middleware.ts configuration
- Verify OAuth credentials in
.env.local - Check redirect URLs in OAuth provider settings
- Google:
http://localhost:3000/api/auth/callback/google - GitHub:
http://localhost:3000/api/auth/callback/github
- Middleware configuration issue
- Check NEXTAUTH_URL setting
- Clear cookies and try again
- Verify domain matches in production
- Check AUTH_SECRET is set
- Verify JWT expiration settings in auth.ts
- Check for clock sync issues
- Check webhook secret (STRIPE_WEBHOOK_SECRET)
- Verify endpoint URL in Stripe dashboard
- Use Stripe CLI for local testing:
stripe listen --forward-to localhost:3000/api/webhooks/stripe- Check webhook is properly configured
- Verify handleStripeWebhook function
- Check Stripe dashboard for event history
- Look for errors in webhook logs
Test Card: 4242 4242 4242 4242
Expiry: Any future date
CVC: Any 3 digits
ZIP: Any 5 digits
- Check webhook logs in Stripe dashboard
- Verify STRIPE_WEBHOOK_SECRET is correct
- Check database for Purchase records
- Look at console logs in webhook handler
# Check for errors
npm run type-check
# Common fixes:
# 1. Regenerate Prisma types
npx prisma generate
# 2. Update dependencies
npm install
# 3. Clear Next.js cache
rm -rf .next# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install- Check tsconfig.json paths configuration
- Verify import paths use correct alias
- Restart TypeScript server in IDE
- Verify RESEND_API_KEY
- Check "from" email is verified domain
- Check email template path
- Review Resend dashboard for errors
- Verify SENDGRID_API_KEY
- Check sender email is verified
- Review SendGrid activity feed
- Check email content for spam triggers
- Check spam folder
- Verify email service is configured
- Check console logs for send errors
- Test with different email provider
# Kill process on port 3000
# Mac/Linux:
lsof -ti:3000 | xargs kill -9
# Windows:
netstat -ano | findstr :3000
taskkill /PID [PID] /F- Check file watcher limits (Linux)
- Restart dev server:
npm run dev - Clear
.nextfolder:rm -rf .next
- Restart dev server after changing
.env.local - Check variable names (no NEXT_PUBLIC_ for server-side)
- Verify
.env.localexists and not in .gitignore - Make sure no spaces around = in .env file
- Using browser API in server component
- Add 'use client' directive
- Check for useEffect/useState in server components
- Check database query efficiency
- Add indexes to frequently queried fields
- Use
selectto limit returned fields - Implement pagination for large datasets
# Clear cache
rm -rf .next
# Check for large dependencies
npx bundle-analyzer- Add indexes in schema.prisma
- Use database query logging
- Optimize WHERE clauses
- Consider Redis for caching
- User session is null
- Add authentication check:
if (!session?.user) return
- Trying to create duplicate record
- Check for existing record first
- Handle P2002 Prisma error code
- Middleware configuration issue
- Check NEXTAUTH_URL setting
- Clear cookies and try again
- Too many requests to API
- Implement exponential backoff
- Check rate limit configuration
- STRIPE_WEBHOOK_SECRET is incorrect
- Using wrong webhook secret (test vs live)
- Payload was modified in transit
// In server actions
console.log('Debug:', { variable1, variable2 })
// In Prisma queries
// Add to db/index.ts
prisma.$on('query', (e) => {
console.log('Query:', e.query)
console.log('Duration:', e.duration, 'ms')
})npx prisma studio
# Opens visual database browser at localhost:5555npm run build
# Look for errors and warnings- Network tab: Check API calls
- Console: Check for errors
- Application tab: Check cookies/local storage
// Add console.logs in server actions
console.log('Session:', session)
console.log('Input:', data)
console.log('Result:', result)- Update Prisma version
- Run
npm install @prisma/client@latest
- Check DATABASE_URL format
- Verify MongoDB is running
- Check network connectivity
- Verify MongoDB Atlas IP whitelist
# Regenerate client
npx prisma generate
# Push changes to database
npx prisma db push- Check endpoint URL is correct
- Verify webhook is enabled
- Check event version compatibility
- Use test keys for development
- Switch to live keys for production
- Verify which mode you're in Stripe dashboard
- Check Stripe customer creation in webhook
- Verify metadata is being passed
- Check for errors in Stripe logs
- Check locale detection in middleware
- Verify translation files exist
- Check browser language settings
- Check translation keys in JSON files
- Verify key exists in all language files
- Add fallback to default language
- Check rtl-detect implementation
- Verify Tailwind directives
- Test with Arabic locale
- Check documentation in
/docs - Review examples in
/examples - Search GitHub issues
- Check Next.js documentation
- Check Prisma documentation
- Review Stripe/Resend documentation
When reporting issues, include:
- Error message (full stack trace)
- Steps to reproduce
- Expected vs actual behavior
- Environment (Node version, OS)
- Relevant code snippets
- Screenshots if applicable
# Check Node version
node -v
# Check npm version
npm -v
# Check installed packages
npm list --depth=0
# Verify environment variables are loaded
echo $DATABASE_URL
# Test database connection
npx prisma db pull
# View generated Prisma client
cat node_modules/.prisma/client/index.d.ts
# Check Next.js info
npx next info