Clean up console logging and fix platform detection issues

- Reduce migration/platform logging verbosity in development mode (~80-90% less noise)
- Fix AbsurdSQL platform check to support 'development' alongside 'web'
- Add missing WebPlatformService methods (isWorker, initSharedArrayBuffer)
- Fix Electron API endpoint resolution to prevent JSON parsing errors
- Prevent circular database logging that caused [DB-PREVENTED-INFO] spam

Console now shows only essential information while preserving all errors/warnings
This commit is contained in:
Matthew Raymer
2025-07-03 06:31:43 +00:00
parent 292aceee75
commit b377667207
8 changed files with 162 additions and 46 deletions

View File

@@ -33,6 +33,31 @@ import { initializeApp } from "./main.common";
import { handleApiError } from "./services/api";
import { logger } from "./utils/logger";
// **CRITICAL**: Disable any existing service workers that might intercept API calls
// Service workers from web sessions can persist and cause issues in Electron
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
navigator.serviceWorker
?.getRegistrations()
.then(function (registrations) {
for (const registration of registrations) {
logger.debug(
"[Electron] Unregistering service worker:",
registration.scope,
);
registration.unregister();
}
if (registrations.length > 0) {
logger.log(
"[Electron] Cleaned up",
registrations.length,
"service worker registrations",
);
}
})
.catch((error) => {
logger.debug("[Electron] Service worker cleanup failed:", error);
});
logger.log("[Electron] Starting initialization");
logger.log("[Electron] Platform:", process.env.VITE_PLATFORM);
@@ -61,14 +86,23 @@ if (typeof window !== "undefined" && window.require) {
// **CRITICAL FIX**: Disable any existing service worker that might be intercepting API calls
try {
if (navigator.serviceWorker?.getRegistrations) {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for(let registration of registrations) {
console.log("[Electron] Unregistering service worker:", registration.scope);
registration.unregister();
}
}).catch(error => {
console.log("[Electron] Failed to unregister service workers:", error);
});
navigator.serviceWorker
.getRegistrations()
.then(function (registrations) {
for (const registration of registrations) {
console.log(
"[Electron] Unregistering service worker:",
registration.scope,
);
registration.unregister();
}
})
.catch((error) => {
console.log(
"[Electron] Failed to unregister service workers:",
error,
);
});
}
} catch (error) {
console.log("[Electron] Service worker cleanup not available:", error);