Troubleshooting¶
Common issues and their solutions when working with Mavric DevEnv.
Setup Issues¶
PostgreSQL Connection Failed¶
Symptom: Backend fails to start with database connection error.
Solutions:
-
Check if PostgreSQL is running:
-
Start PostgreSQL container:
-
Verify connection string:
-
Check port availability:
Port Already in Use¶
Symptom: Server fails to start because port is occupied.
Solutions:
-
Find process using the port:
-
Kill the process:
-
Or use a different port:
Missing Dependencies¶
Symptom: Module not found errors.
Solutions:
-
Install dependencies:
-
Clear node_modules and reinstall:
Authentication Issues¶
AUTH_SECRET Not Configured¶
Symptom: Auth fails with secret error.
Solution:
Generate a secure secret and add to .env:
# Generate secret
openssl rand -base64 32
# Add to backend/.env
AUTH_SECRET=your-generated-secret-here
Session Not Persisting¶
Symptom: User gets logged out unexpectedly.
Solutions:
-
Check cookie settings:
-
Verify CORS credentials:
-
Check frontend fetch calls:
CORS Errors¶
Symptom: Browser blocks API requests.
Access to fetch at 'http://localhost:3001' from origin 'http://localhost:3000' has been blocked by CORS policy
Solution:
Configure CORS in backend:
// main.ts
app.enableCors({
origin: process.env.CORS_ORIGIN || 'http://localhost:3000',
credentials: true,
});
Apso Issues¶
Scaffold Command Fails¶
Symptom: apso scaffold exits with error.
Solutions:
-
Validate .apsorc syntax:
-
Check entity names:
- Must be PascalCase
- No reserved words
-
No special characters
-
Verify field types:
DTO Import Errors¶
Symptom: TypeScript errors about missing DTO exports.
Solution:
Run the DTO fix script:
Or manually check autogen/Entity/dtos/index.ts exports.
Entity Relationship Errors¶
Symptom: Foreign key constraint failures.
Solutions:
-
Check relationship definitions in .apsorc:
-
Ensure referenced entities exist:
-
Run migrations:
Database Issues¶
Migration Failures¶
Symptom: Database schema doesn't match entities.
Solutions:
-
Generate new migration:
-
Run pending migrations:
-
Reset database (development only):
Duplicate Key Errors¶
Symptom: Insert fails with unique constraint violation.
Solutions:
-
Check for existing data:
-
Handle in code:
Frontend Issues¶
Hydration Mismatch¶
Symptom: React hydration error in Next.js.
Solutions:
-
Use client components for dynamic content:
-
Suppress hydration warning (last resort):
API Fetch Failures¶
Symptom: API calls fail in production but work locally.
Solutions:
-
Check environment variables:
-
Use absolute URLs in server components:
Testing Issues¶
Step Definition Not Found¶
Symptom: Cucumber can't find step implementation.
Solution:
Ensure step definition exists and matches:
// step-definitions/common/auth.steps.ts
import { Given } from '@cucumber/cucumber';
Given('I am logged in', async function() {
// Implementation
});
Test Database Conflicts¶
Symptom: Tests fail due to data from other tests.
Solutions:
-
Use test database:
-
Clean database between tests:
Performance Issues¶
Slow API Responses¶
Solutions:
-
Add database indexes:
-
Select only needed fields:
-
Use pagination:
N+1 Query Problem¶
Symptom: Many database queries for related data.
Solution:
Use eager loading:
// Instead of loading relations separately
const projects = await this.projectRepo.find({
relations: ['members', 'tasks'],
});
Getting Help¶
If you can't resolve an issue:
-
Check logs:
-
Enable debug mode:
-
Search existing issues:
- Check project issue tracker
-
Search error message online
-
Provide details when asking for help:
- Exact error message
- Steps to reproduce
- Environment (OS, Node version)
- Relevant log output