From be3808fa5c9f6657bc014bae4782a2cb5625f698 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 25 May 2026 16:27:39 -0700 Subject: [PATCH] [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) --- electron/package.json | 2 +- frontend/src/app/Main.tsx | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/electron/package.json b/electron/package.json index 3f18cd44..1df5c15f 100644 --- a/electron/package.json +++ b/electron/package.json @@ -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", diff --git a/frontend/src/app/Main.tsx b/frontend/src/app/Main.tsx index fdd9ebb3..bdea6784 100644 --- a/frontend/src/app/Main.tsx +++ b/frontend/src/app/Main.tsx @@ -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;