feat: enhance mobile compatibility and debugging across authentication and system metrics
All checks were successful
Build And Push Image / docker (push) Successful in 3m18s
All checks were successful
Build And Push Image / docker (push) Successful in 3m18s
This commit is contained in:
@@ -36,14 +36,15 @@ export async function getSystemMetrics(): Promise<SystemMetrics> {
|
||||
|
||||
// Return cached data if still valid
|
||||
if (metricsCache && (now - lastCacheTime) < CACHE_DURATION) {
|
||||
console.log('📊 Returning cached system metrics');
|
||||
return metricsCache;
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('🔄 Fetching fresh system metrics...');
|
||||
|
||||
// Get all metrics in parallel for better performance
|
||||
const [cpuData, memData, fsData, currentLoad, processData, uptimeData] = await Promise.all([
|
||||
// Get all metrics in parallel with individual error handling
|
||||
const results = await Promise.allSettled([
|
||||
si.cpu(),
|
||||
si.mem(),
|
||||
si.fsSize(),
|
||||
@@ -52,8 +53,24 @@ export async function getSystemMetrics(): Promise<SystemMetrics> {
|
||||
si.time()
|
||||
]);
|
||||
|
||||
// Extract data with fallbacks for failed promises
|
||||
const cpuData = results[0].status === 'fulfilled' ? results[0].value : { cores: 0, brand: 'Unknown' };
|
||||
const memData = results[1].status === 'fulfilled' ? results[1].value : { total: 0, used: 0, free: 0 };
|
||||
const fsData = results[2].status === 'fulfilled' ? results[2].value : [];
|
||||
const currentLoad = results[3].status === 'fulfilled' ? results[3].value : { currentLoad: 0 };
|
||||
const processData = results[4].status === 'fulfilled' ? results[4].value : { all: 0, running: 0, sleeping: 0 };
|
||||
const uptimeData = results[5].status === 'fulfilled' ? results[5].value : { uptime: 0 };
|
||||
|
||||
// Log any failures
|
||||
results.forEach((result, index) => {
|
||||
if (result.status === 'rejected') {
|
||||
const names = ['CPU', 'Memory', 'Filesystem', 'CPU Load', 'Processes', 'Uptime'];
|
||||
console.warn(`⚠️ ${names[index]} data failed:`, result.reason?.message || result.reason);
|
||||
}
|
||||
});
|
||||
|
||||
// Calculate disk totals across all mounted filesystems
|
||||
const diskTotals = fsData.reduce((acc, fs) => {
|
||||
const diskTotals = (fsData as any[]).reduce((acc: { total: number; used: number }, fs: any) => {
|
||||
// Skip special filesystems and focus on main storage
|
||||
if (fs.type && !['tmpfs', 'devtmpfs', 'proc', 'sysfs'].includes(fs.type.toLowerCase())) {
|
||||
acc.total += fs.size || 0;
|
||||
|
||||
Reference in New Issue
Block a user