Enhanced: Comprehensive production debugging and Nginx proxy support

Debugging Tools:
- Added /debug endpoint to verify deployment and test distribution functionality
- Added browser console test function: testDistributionChart()
- Enhanced SocketIO settings with better transport priorities
- Added comprehensive error tracking and status reporting

Nginx Configuration:
- Created NGINX_CONFIG.md with complete proxy setup guide
- Improved WebSocket transport settings and timeouts
- Better ping/pong settings for connection stability

Production Compatibility:
- Optimized SocketIO for proxy environments
- Enhanced fallback mechanisms
- Production-ready logging and error handling

This should resolve proxy-related issues and provide clear diagnostic tools.
This commit is contained in:
2025-08-24 18:53:09 +00:00
parent 6f94b1bd04
commit 97e9e18ee5
4 changed files with 211 additions and 3 deletions

View File

@@ -1,3 +1,63 @@
/**
* Production debugging test function
* Call from browser console: testDistributionChart()
*/
window.testDistributionChart = function() {
debugLog('=== DISTRIBUTION CHART DIAGNOSTIC TEST ===');
// Test 1: Check if elements exist
const canvas = document.getElementById('distributionChart');
debugLog('Canvas element found', !!canvas);
// Test 2: Check Chart.js availability
debugLog('Chart.js available', typeof Chart !== 'undefined');
// Test 3: Check chart instance
debugLog('Chart instance exists', !!charts.distribution);
// Test 4: Check current data
debugLog('Current simulation data', {
hasId: !!currentSimulation.id,
isRunning: currentSimulation.isRunning,
distributionData: currentSimulation.data.distribution
});
// Test 5: Check WebSocket connection
debugLog('WebSocket status', {
socketExists: !!window.MarkovEconomics.socket,
isConnected: window.MarkovEconomics ? window.MarkovEconomics.isConnected : 'unknown'
});
// Test 6: Manually test API endpoint
if (currentSimulation.id) {
fetch(`/api/simulation/${currentSimulation.id}/distribution?bins=5`)
.then(response => response.json())
.then(data => {
debugLog('Manual API test result', data);
})
.catch(error => {
debugLog('Manual API test failed', error);
});
}
// Test 7: Try to create test data and update chart
if (charts.distribution) {
const testLabels = ['$0-100', '$100-200', '$200-300'];
const testCounts = [5, 8, 2];
try {
charts.distribution.data.labels = testLabels;
charts.distribution.data.datasets[0].data = testCounts;
charts.distribution.update();
debugLog('Manual chart update test: SUCCESS');
} catch (error) {
debugLog('Manual chart update test: FAILED', error);
}
}
debugLog('=== TEST COMPLETE ===');
};
// Debug flag - can be enabled even in production for troubleshooting
const DEBUG_DISTRIBUTION = true;