[eric] diag: add global window.onerror + unhandledrejection handlers in Main.tsx so packaged-build stderr captures the stack trace of the "Cannot read properties of undefined (reading 'sessionId')" throw firing inside AgentChat's render path (bundle.js:2 alone is uninformative without source maps)

This commit is contained in:
Eric
2026-05-25 16:27:39 -07:00
parent d27f289cea
commit be3808fa5c
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "openswarm",
"version": "1.1.45",
"version": "1.1.46",
"description": "OpenSwarm — AI Agent Orchestrator",
"author": "openswarm-ai",
"main": "main.js",
+15
View File
@@ -33,6 +33,21 @@ const OnboardingRoot = lazy(() =>
const SignInGate = lazy(() => import('./components/overlays/SignInGate'));
if (typeof window !== 'undefined') {
// Diagnostic global error capture. The packaged bundle has no source maps, so without these handlers the only thing that reaches main-process stderr is "Uncaught TypeError: ... (bundle.js:2)" with zero stack context. Forward error.stack and Redux action.type when available so we can pinpoint the offender across the chat-spawn / workflow rendering paths even in minified prod.
window.addEventListener('error', (e) => {
try {
// eslint-disable-next-line no-console
console.error('[diag][window.error]', e.message, '@', e.filename, ':', e.lineno, ':', e.colno, '\nstack:\n', e.error && (e.error as Error).stack);
} catch { /* never let the handler itself throw */ }
});
window.addEventListener('unhandledrejection', (e) => {
try {
const reason = (e as PromiseRejectionEvent).reason;
// eslint-disable-next-line no-console
console.error('[diag][window.unhandledrejection]', reason && reason.message, '\nstack:\n', reason && reason.stack);
} catch { /* never let the handler itself throw */ }
});
(window as any).__openswarmPrefetchRoute = (path: string) => {
switch (path) {
case '/skills': void import('./pages/Skills/Skills'); return;