commit 2 refactor

This commit is contained in:
Boki 2026-10-20 14:35:45 -04:00
parent 588f666943
commit 32e43c9243
310 changed files with 33318 additions and 31189 deletions

View file

@ -1,47 +1,51 @@
// Global error handler for chart disposal errors
export function setupChartErrorHandler() {
// Only suppress chart disposal errors during page unload
let isUnloading = false;
window.addEventListener('beforeunload', () => {
isUnloading = true;
});
window.addEventListener('unload', () => {
isUnloading = true;
});
// Intercept console errors for chart disposal
const originalError = console.error;
console.error = (...args) => {
// Check if this is a chart disposal error during unload
if (isUnloading) {
const errorStr = args.join(' ');
if (errorStr.includes('Object is disposed') ||
errorStr.includes('Cannot read properties of null') ||
errorStr.includes('lightweight-charts')) {
// Suppress the error during unload
return;
}
}
// Otherwise, log normally
originalError.apply(console, args);
};
// Also catch unhandled errors
window.addEventListener('error', (event) => {
if (isUnloading && event.error?.message?.includes('Object is disposed')) {
event.preventDefault();
return;
}
});
// Catch unhandled promise rejections
window.addEventListener('unhandledrejection', (event) => {
if (isUnloading && event.reason?.message?.includes('Object is disposed')) {
event.preventDefault();
return;
}
});
}
import { browserLog } from '@/utils/browserLog';
// Global error handler for chart disposal errors
export function setupChartErrorHandler() {
// Only suppress chart disposal errors during page unload
let isUnloading = false;
window.addEventListener('beforeunload', () => {
isUnloading = true;
});
window.addEventListener('unload', () => {
isUnloading = true;
});
// Intercept console errors for chart disposal
const originalError = browserLog.error;
browserLog.error = (...args) => {
// Check if this is a chart disposal error during unload
if (isUnloading) {
const errorStr = args.join(' ');
if (
errorStr.includes('Object is disposed') ||
errorStr.includes('Cannot read properties of null') ||
errorStr.includes('lightweight-charts')
) {
// Suppress the error during unload
return;
}
}
// Otherwise, log normally
originalError.apply(console, args);
};
// Also catch unhandled errors
window.addEventListener('error', event => {
if (isUnloading && event.error?.message?.includes('Object is disposed')) {
event.preventDefault();
return;
}
});
// Catch unhandled promise rejections
window.addEventListener('unhandledrejection', event => {
if (isUnloading && event.reason?.message?.includes('Object is disposed')) {
event.preventDefault();
return;
}
});
}