LIMS Support Analyst Debug Guide

How to Actually Use This Guide

Step 1: Setup Monitoring (Run Once Per LIMS Session)

Open F12 → Console → Paste this when you first load the LIMS site:


// Setup error monitoring
window.addEventListener('error', function(e) {
    console.log('🔴 Error:', e.message, 'at', e.filename + ':' + e.lineno);
});

// Monitor API calls
const originalFetch = window.fetch;
window.fetch = function(...args) {
    return originalFetch.apply(this, args).then(response => {
        if (!response.ok) {
            console.log(`🔴 API Error: ${args[0]} - Status: ${response.status}`);
        }
        return response;
    });
};

console.log('✅ Monitoring setup complete');

Step 2: User Reports Issue → Run Specific Diagnostics

#### User Says "Upload Not Working"


// Paste this, then ask user to try upload again
document.querySelectorAll('input[type="file"]').forEach(input => {
    input.addEventListener('change', function(e) {
        const file = e.target.files[0];
        if (file) {
            console.log('📁 File Details:', {
                name: file.name,
                size: `${(file.size / 1024 / 1024).toFixed(2)} MB`,
                type: file.type
            });
            if (file.size > 50 * 1024 * 1024) {
                console.log('⚠️ File too large - over 50MB');
            }
        }
    });
});

#### User Says "Search Returns Nothing"


// Monitor search API calls
document.querySelectorAll('input[type="search"], input[name*="search"]').forEach(input => {
    input.addEventListener('input', function() {
        console.log('🔍 Search triggered:', this.value);
    });
});

#### User Says "Login Keeps Failing"


// Monitor auth issues
document.querySelectorAll('form').forEach(form => {
    if (form.action.includes('login') || form.action.includes('auth')) {
        form.addEventListener('submit', function() {
            console.log('🔐 Login attempt detected');
            setTimeout(() => {
                if (window.location.href.includes('login')) {
                    console.log('❌ Login failed - still on login page');
                } else {
                    console.log('✅ Login successful');
                }
            }, 1000);
        });
    }
});

#### User Says "Page Loading Forever"


// Check what's hanging
console.log('🕐 Checking slow resources...');
performance.getEntriesByType('resource').forEach(resource => {
    if (resource.duration > 5000) {
        console.log(`🐌 Slow resource: ${resource.name} took ${resource.duration.toFixed(0)}ms`);
    }
});

Step 3: Quick Health Check (When Everything's Broken)


// Paste this for quick system status
console.log('=== Quick Health Check ===');
console.log('Storage errors:', localStorage.length, sessionStorage.length);
console.log('Cookies:', document.cookie.split(';').length);
console.log('Network:', navigator.onLine);
console.log('Page errors:', document.querySelectorAll('.error, .alert-danger').length);

Real Example: "Sample Upload Failing"

User calls: "I can't upload my sample data file"

You do:

1. Open LIMS site → F12 → Console → Paste Step 1 monitoring code

2. Paste upload diagnostic code from Step 2

3. "Can you try uploading the file again while I watch?"

4. User uploads → Console shows:


   📁 File Details: {name: "samples.csv", size: "67.43 MB", type: "text/csv"}
   ⚠️ File too large - over 50MB
   🔴 API Error: /api/upload - Status: 413

5. Actual fix: "The file is too large. Can you split it into smaller files under 50MB?"

Before this method: "Upload failed. Contact administrator."

After this method: "File too large. Split into sub-50MB files."

Advanced Diagnostics

Storage and Session Issues


// Check for corrupted session data causing issues
function checkStorage() {
    console.log('=== Storage Analysis ===');
    
    // Check localStorage for corruption
    for (let i = 0; i < localStorage.length; i++) {
        const key = localStorage.key(i);
        const value = localStorage.getItem(key);
        try {
            JSON.parse(value);
        } catch (e) {
            console.log(`❌ Corrupted localStorage: ${key}`);
        }
    }
    
    // Check sessionStorage
    for (let i = 0; i < sessionStorage.length; i++) {
        const key = sessionStorage.key(i);
        const value = sessionStorage.getItem(key);
        try {
            JSON.parse(value);
        } catch (e) {
            console.log(`❌ Corrupted sessionStorage: ${key}`);
        }
    }
    
    // Check cookies for expiration issues
    document.cookie.split(';').forEach(cookie => {
        if (cookie.includes('expires=')) {
            const expiry = cookie.split('expires=')[1];
            if (new Date(expiry) < new Date()) {
                console.log(`❌ Expired cookie: ${cookie}`);
            }
        }
    });
}

checkStorage();

Form Validation Issues


// Check form validation issues
function debugForms() {
    document.querySelectorAll('form').forEach(form => {
        form.addEventListener('submit', function(e) {
            const invalidFields = form.querySelectorAll(':invalid');
            if (invalidFields.length > 0) {
                console.log('🔴 Form validation errors:');
                invalidFields.forEach(field => {
                    console.log(`Field: ${field.name}, Error: ${field.validationMessage}`);
                });
            }
        });
    });
}

debugForms();

Performance and Memory Monitoring

Memory Usage Check


// Check for memory leaks
function checkMemory() {
    if (performance.memory) {
        const used = (performance.memory.usedJSHeapSize / 1048576).toFixed(2);
        const total = (performance.memory.totalJSHeapSize / 1048576).toFixed(2);
        const limit = (performance.memory.jsHeapSizeLimit / 1048576).toFixed(2);
        
        console.log(`Memory: ${used}MB used / ${total}MB total / ${limit}MB limit`);
        
        if (used > limit * 0.8) {
            console.log('⚠️ High memory usage detected');
        }
    }
}

// Check memory every 30 seconds
setInterval(checkMemory, 30000);

Security Audit Tools (for reporting vulnerabilities)

Input Validation Testing


// Test input fields for proper validation
function testInputValidation() {
    const testCases = [
        '<script>alert("test")</script>', // XSS
        "'; DROP TABLE test; --", // SQL injection
        '../../../etc/passwd', // Path traversal
        'A'.repeat(1000) // Buffer overflow
    ];
    
    document.querySelectorAll('input[type="text"], textarea').forEach(input => {
        testCases.forEach(testCase => {
            input.value = testCase;
            input.dispatchEvent(new Event('change'));
            
            // Check if any client-side validation triggered
            if (input.checkValidity && !input.checkValidity()) {
                console.log(`✅ Input validation working on: ${input.name || input.id}`);
            } else {
                console.log(`⚠️ No client validation on: ${input.name || input.id} for: ${testCase.substring(0, 20)}...`);
            }
        });
    });
}

Database and File System Diagnostics

Database Error Detection


// Monitor for database connection errors
const dbErrorPatterns = [
    'connection pool',
    'timeout',
    'deadlock',
    'lock wait timeout',
    'connection refused',
    'max connections'
];

// Override console.error to catch DB errors
const originalConsoleError = console.error;
console.error = function(...args) {
    const errorText = args.join(' ').toLowerCase();
    dbErrorPatterns.forEach(pattern => {
        if (errorText.includes(pattern)) {
            console.log(`🔴 Database Issue Detected: ${pattern}`);
        }
    });
    originalConsoleError.apply(console, args);
};

Session Timeout Monitoring


// Monitor for session timeouts
let lastActivity = Date.now();

['click', 'keypress', 'scroll', 'mousemove'].forEach(event => {
    document.addEventListener(event, () => {
        lastActivity = Date.now();
    });
});

function checkSessionTimeout() {
    const inactiveTime = Date.now() - lastActivity;
    const inactiveMinutes = Math.floor(inactiveTime / 60000);
    
    if (inactiveMinutes > 30) { // 30 minutes
        console.log(`⚠️ User inactive for ${inactiveMinutes} minutes - potential session timeout`);
    }
}

setInterval(checkSessionTimeout, 60000); // Check every minute

Support Note Templates

Error Report Template


## Error Report

**Date/Time:** [timestamp]
**User:** [username]
**Browser:** [navigator.userAgent]
**URL:** [window.location.href]

### Symptoms
- What the user was trying to do
- What they expected to happen
- What actually happened

### Technical Details
- Console errors: [from F12 console]
- Network failures: [from Network tab]
- Storage issues: [from Application tab]

### Reproduction Steps
1. Step 1
2. Step 2
3. Error occurs

### Workaround
[If any temporary fix available]

### Resolution
[Final fix applied]

Performance Issue Template


## Performance Issue

**Date/Time:** [timestamp]
**Affected Users:** [count/department]
**Severity:** [High/Medium/Low]

### Performance Metrics
- Page load time: [from Network tab]
- API response times: [slow calls detected]
- Memory usage: [if applicable]

### Root Cause
[Database slow query / Large file processing / etc.]

### Fix Applied
[Technical solution]

### Prevention
[How to avoid in future]