Troubleshooting
Common issues and solutions for FastSvelte development and deployment.
Setup Issues
Init script prerequisites not met
Solution: Install all required tools: - Python 3.12+: https://www.python.org/downloads/ - Docker: https://docs.docker.com/get-docker/ - Node.js 22+: https://nodejs.org/ - Sqitch: https://sqitch.org/download/Init script permission denied
Solution: Make the script executable:Port conflicts during init
Solution: Stop services using required ports (5432, 8000, 5173, 5174):Docker daemon not running
Solution: Start Docker:pip install fails with dependency conflicts
Solution: Update Python to 3.12+ and use clean virtual environment:python3.12 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
PostgreSQL connection refused
Solution: Ensure PostgreSQL is running:# Using Docker
docker compose up db -d
# Check if running
docker ps | grep postgres
# Verify connection
psql postgres://postgres:postgres@localhost/fastsvelte -c "SELECT 1;"
Database does not exist
Solution: Create the database:# Connect to PostgreSQL and create database
psql postgres://postgres:postgres@localhost -c "CREATE DATABASE fastsvelte;"
# Or use Docker
docker exec -it fastsvelte-db psql -U postgres -c "CREATE DATABASE fastsvelte;"
Development Issues
API client generation fails
Solution: Ensure backend is running before generating client:# Start backend first
cd backend && uvicorn app.main:app --reload
# Then generate in another terminal
cd frontend && npm run generate
Import errors with absolute imports
Solution: Always use absolute imports fromapp package:
# ✅ Correct
from app.service.user_service import UserService
# ❌ Incorrect
from ..service.user_service import UserService
Dependency injection not working
Solution: Ensure your module is added to wiring configuration:# app/config/container.py
wiring_config = containers.WiringConfiguration(
modules=[
"app.api.route.your_new_route", # Add this line
# ... existing modules
]
)
Hot reload not working
Solution: Check file watchers and ports:# Backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Frontend
npm run dev -- --host 0.0.0.0 --port 5173
Database Issues
Migration fails with "relation already exists"
Solution: UseIF NOT EXISTS in migrations:
Sqitch deploy fails with permission denied
Solution: Make script executable:Connection pool exhausted
Solution: Adjust connection pool settings:# app/data/db_config.py
self.pool = await asyncpg.create_pool(
self.dsn,
min_size=5, # Reduce if needed
max_size=10, # Reduce if needed
command_timeout=60
)
Docker volumes not mounting
Solution: Create external volume:Frontend Issues
CORS errors in development
Solution: Check CORS configuration in backend:# app/config/settings.py
@property
def cors_origins(self) -> list[str]:
return {
"dev": ["http://localhost:5173", "http://localhost:4173"],
# ... other environments
}.get(self.environment, [])
Authentication not persisting
Solution: Ensure cookies are configured properly:// src/lib/api/axios.js
export const axiosInstance = Axios.create({
baseURL: PUBLIC_API_BASE_URL,
withCredentials: true // This is crucial
});
Svelte components not updating
Solution: Use Svelte 5 runes correctly:Production Issues
Static assets not loading
Solution: Check build configuration and base path:Database connection timeouts in production
Solution: Increase connection timeout and pool settings:High memory usage
Solution: Optimize container resources and add memory limits:# Dockerfile
FROM python:3.12-slim # Use slim image
# Add memory-efficient settings
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
SSL certificate errors
Solution: Ensure proper SSL configuration:# Check certificate
openssl s_client -connect yourdomain.com:443
# Verify DNS
nslookup yourdomain.com
Performance Issues
Slow database queries
Solution: Add indexes and optimize queries:-- Find slow queries
SELECT query, mean_exec_time, calls
FROM pg_stat_statements
WHERE mean_exec_time > 100
ORDER BY mean_exec_time DESC;
-- Add missing indexes
CREATE INDEX CONCURRENTLY idx_user_organization_active
ON fastsvelte."user"(organization_id) WHERE is_active = true;
Memory usage constantly increasing
Solution: Check for memory leaks:# Add connection cleanup
async def cleanup_connections():
await db_config.pool.close()
# Monitor connection pools
async def get_pool_status():
return {
"size": db_config.pool.get_size(),
"active": db_config.pool.get_active_count(),
"idle": db_config.pool.get_idle_count()
}
Security Issues
Users accessing protected routes without login
Solution: Verify route protection:@router.get("/admin/users")
async def list_users(
current_user: CurrentUser = Depends(min_role_required(Role.SYSTEM_ADMIN))
):
# Ensure dependency is applied
Sessions being stolen or reused Solution: Implement proper session security:
# Rotate session tokens on login
async def login(email: str, password: str):
# ... authenticate user
# Generate new session token
new_token = secrets.token_urlsafe(32)
# Invalidate old sessions for this user
await session_repo.delete_by_user_id(user.id)
# Create new session
await session_repo.create(user.id, hash_token(new_token))
Monitoring & Debugging
View backend logs:
View frontend logs: - Open browser DevTools → Console - Check Network tab for API errors - Monitor Application tab for localStorage/cookies
Check database connections:
API health check:
Getting Help
When reporting issues, include:
- Environment details - Development/production, OS, versions
- Error messages - Complete error traces and logs
- Configuration - Relevant environment variables (sanitized)
- Steps to reproduce - Minimal reproduction steps
- Expected behavior - What should happen vs what actually happens
Resources: - Architecture Overview - Understanding the system - Development Guide - Development workflows - Integrations - External service configuration