Troubleshooting - chintan992/letsstream2 GitHub Wiki
Troubleshooting Guide
This guide helps you diagnose and fix common issues in Let's Stream V2.0.
Common Issues
Build Problems
1. TypeScript Errors
Error: Cannot find module '@/components' or its corresponding type declarations.
Solution:
- Check path aliases in
tsconfig.json
- Verify file exists in correct location
- Run
npm install
to update dependencies - Clear TypeScript cache:
rm -rf node_modules/.cache
2. Vite Build Failures
Error: Failed to resolve import "xyz" from "src/App.tsx"
Solution:
- Clear Vite cache:
rm -rf node_modules/.vite
- Verify import path
- Check file extensions
- Update Vite config if needed
Authentication Issues
1. Firebase Auth Errors
// Common error: Invalid API key
FirebaseError: Invalid API key provided
Solution:
- Verify environment variables
- Check Firebase console configuration
- Ensure authorized domains are set
- Clear browser cache and cookies
2. OAuth Problems
Error: redirect_uri_mismatch
Solution:
- Add domain to authorized redirect URIs
- Check Google Cloud Console settings
- Verify OAuth consent screen
- Update Firebase authentication settings
PWA Features
1. Service Worker Not Registering
// Service worker registration failed
Error: Registration failed - Service worker not found
Solution:
- Check service worker path
- Verify HTTPS or localhost
- Clear browser cache
- Check browser console for errors
2. Offline Mode Issues
// Cache storage problems
Error: QuotaExceededError
Solution:
- Clear site data
- Adjust cache size limits
- Review caching strategy
- Check storage quota
Performance Issues
1. Slow Initial Load
Symptoms:
- Long First Contentful Paint
- Poor Lighthouse score
- High bundle size
Solution:
- Enable code splitting:
// Add dynamic imports
const Component = lazy(() => import('./Component'));
-
Optimize images:
- Use WebP format
- Implement lazy loading
- Set proper dimensions
-
Review bundle size:
npm run build -- --report
2. Memory Leaks
Symptoms:
- Growing memory usage
- Browser tab crashes
- Performance degradation
Solution:
- Clean up event listeners
- Cancel async operations
- Clear intervals/timeouts
- Use proper cleanup in useEffect
API Issues
1. Rate Limiting
// Rate limit exceeded
Error: Too many requests
Solution:
- Implement request queuing:
const rateLimiter = new RateLimiter({
maxRequests: 100,
timeWindow: 60000
});
- Add retry logic:
const fetchWithRetry = async (url, options, retries = 3) => {
try {
return await fetch(url, options);
} catch (error) {
if (retries > 0) {
await new Promise(resolve => setTimeout(resolve, 1000));
return fetchWithRetry(url, options, retries - 1);
}
throw error;
}
};
2. CORS Issues
Access to fetch at 'URL' has been blocked by CORS policy
Solution:
- Add proper CORS headers
- Use proxy in development
- Update API configuration
- Check server settings
State Management
1. Context Updates Not Reflecting
Symptoms:
- UI not updating
- Stale data
- Inconsistent state
Solution:
- Verify context provider wrapper
- Check dependency arrays
- Use proper state updates
- Implement proper memoization
2. React Query Cache Issues
// Stale data in cache
const { data } = useQuery(['key'], fetcher, {
staleTime: 1000 * 60 * 5, // 5 minutes
cacheTime: 1000 * 60 * 30 // 30 minutes
});
Solution:
- Adjust cache settings
- Manual cache invalidation
- Force refetch when needed
- Clear query cache
Debugging Tools
1. Chrome DevTools
- Network tab for API calls
- Application tab for PWA/storage
- Performance tab for metrics
- Sources tab for debugging
2. React DevTools
- Components tab for hierarchy
- Profiler for performance
- Props/state inspection
- Context viewing
3. Firebase Console
- Authentication status
- Database operations
- Analytics data
- Error reporting
4. Logging Utilities
// Enhanced logging
const logger = {
info: (message: string, data?: any) => {
if (process.env.NODE_ENV === 'development') {
console.log(`[INFO] ${message}`, data);
}
},
error: (message: string, error: Error) => {
console.error(`[ERROR] ${message}`, error);
// Add error reporting service here
}
};
Error Boundaries
Implementation
class ErrorBoundary extends React.Component {
state = { hasError: false, error: null };
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
componentDidCatch(error, errorInfo) {
logger.error('Error boundary caught error:', error);
// Report to error service
}
render() {
if (this.state.hasError) {
return <ErrorFallback error={this.state.error} />;
}
return this.props.children;
}
}
Usage
<ErrorBoundary>
<Route path="/media/:id" component={MediaPlayer} />
</ErrorBoundary>
Testing Issues
1. Failed Tests
Problem: Tests failing after changes
Solution:
- Update test snapshots:
npm test -- -u
- Check test environment
- Update mock data
- Verify test coverage
2. Integration Test Failures
Problem: E2E tests failing
Solution:
- Check test environment
- Update test data
- Verify API mocks
- Check browser compatibility
Production Issues
1. Deployment Failures
Problem: Build fails in production
Solution:
- Check environment variables
- Verify build configuration
- Test in production mode locally
- Review deployment logs
2. Runtime Errors
Problem: Errors in production environment
Solution:
- Enable source maps
- Implement error tracking
- Add logging service
- Monitor performance metrics
Support Resources
Documentation
- React documentation
- Firebase guides
- Vite documentation
- TailwindCSS docs
Community
- GitHub issues
- Stack Overflow
- Discord server
- Developer forums
Tools
- Browser DevTools
- React DevTools
- Firebase Console
- VS Code debugger