Troubleshooting
This guide covers common issues you may encounter when implementing SSR with Aurelia and their solutions.
Common Setup Issues
Build Errors
Error: "Cannot resolve 'aurelia-pal'"
Symptoms:
Module not found: Error: Can't resolve 'aurelia-pal' in '/path/to/project'Solution: Ensure you have installed the Node.js PAL package:
npm install aurelia-pal-nodejsAnd initialize it in your server entry point:
import { initialize } from 'aurelia-pal-nodejs';
initialize();Error: "aurelia-bootstrapper not found"
Symptoms:
Module not found: Error: Can't resolve 'aurelia-bootstrapper'Solution: This usually happens when webpack is trying to load the client bootstrapper on the server. Ensure your server configuration uses the correct entry point:
// Server webpack config
{
entry: './src/server-main.ts', // Not aurelia-bootstrapper
target: 'node'
}Runtime Errors
Error: "window is not defined"
Symptoms:
Cause: Your code is trying to access browser globals in the server environment.
Solution:
Use environment checks:
Use PAL abstractions:
Error: "document is not defined"
Symptoms:
Solution: Replace direct DOM access with PAL:
Error: "localStorage is not defined"
Symptoms:
Solution: Add environment checks or provide server-side alternatives:
Memory and Performance Issues
Memory Leaks
Symptoms:
Server memory usage continuously increases
Server becomes unresponsive over time
"Out of memory" errors
Debugging Memory Leaks:
Monitor memory usage:
Check for common causes:
Slow Rendering Performance
Symptoms:
Server response times are slow
High CPU usage during rendering
Solutions:
Profile your rendering:
Optimize heavy operations:
Rendering Issues
Content Not Appearing
Symptoms:
Page renders but content is missing
"Loading..." or placeholder content shows
Solutions:
Check async operations:
Verify template syntax:
Hydration Mismatches
Symptoms:
Content flickers when client takes over
Console warnings about hydration mismatches
Solutions:
Ensure consistent rendering:
Use proper conditional rendering:
Debugging Techniques
Enable Debug Logging
Add detailed logging to understand the rendering process:
Use Node.js Debugger
Start with debugging enabled:
Open Chrome DevTools:
Navigate to
chrome://inspectClick "Open dedicated DevTools for Node"
Server-Side Console Output
Add strategic console.log statements:
Error Boundary Implementation
Create error boundaries to catch and handle SSR errors gracefully:
Configuration Issues
Webpack Bundle Problems
Symptoms:
"Module not found" errors in production
Different behavior between development and production
Solutions:
Check externals configuration:
Verify output configuration:
Middleware Configuration
Common middleware issues:
Deployment Issues
Production Environment Problems
Environment variable configuration:
Process management:
Docker Considerations
If using Docker, ensure proper Node.js and build setup:
Getting Help
If you're still experiencing issues:
Check the browser console for client-side errors
Review server logs for detailed error information
Test with JavaScript disabled to verify SSR is working
Compare with a minimal SSR setup to isolate the problem
Search the Aurelia GitHub issues for similar problems
Ask on the Aurelia Discord or forums for community help
Performance Monitoring
Set up monitoring to catch issues early:
Remember that SSR debugging can be complex due to the dual-environment nature. Always test both server-side rendering and client-side hydration to ensure your application works correctly in all scenarios.
Last updated
Was this helpful?