Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([codex5-client-error-reporter]): never-throws also covers JSON.stringify
[._.]/ Adam Eivy312ab866b557
diff --git a/client/src/lib/clientErrorReporter.js b/client/src/lib/clientErrorReporter.jsindex 374a725f4a..4af6f99e2b 100644--- a/client/src/lib/clientErrorReporter.js+++ b/client/src/lib/clientErrorReporter.js@@ -106,8 +106,8 @@ export function buildPayload(input) {if (input.error instanceof Error) {return {...base,- message: input.error.message || input.message || 'Unknown error',- stack: input.error.stack,+ message: safeGet(input.error, 'message') || input.message || 'Unknown error',+ stack: coerceStack(safeGet(input.error, 'stack')),source: input.filename,line: input.lineno,column: input.colno,@@ -123,6 +123,22 @@ export function buildPayload(input) {};}+// Build the request body so that any non-serializable value on `stack` /+// `message` (BigInt, Symbol, throwing toJSON) can't slip past the try block+// and reject inside the fetch call. Falls back to a degraded payload that+// keeps the type + truncated message rather than dropping the report.+function safeBody(payload) {+ try {+ return JSON.stringify(payload);+ } catch {+ return JSON.stringify({+ type: payload.type,+ message: safeToString(payload.message),+ stack: '[unserializable]',+ });+ }+}+/*** Report a client-side error. Resolves to:* - `{ sent: true }` — sent to the server.@@ -165,7 +181,7 @@ export async function reportClientError(input) {const ok = await fetch(ENDPOINT, {method: 'POST',headers: { 'Content-Type': 'application/json' },- body: JSON.stringify(payload),+ body: safeBody(payload),keepalive: true,}).then(r => r.ok).catch(() => false);diff --git a/client/src/lib/clientErrorReporter.test.js b/client/src/lib/clientErrorReporter.test.jsindex d985cac85a..0ba1c66ecc 100644--- a/client/src/lib/clientErrorReporter.test.js+++ b/client/src/lib/clientErrorReporter.test.js@@ -64,6 +64,39 @@ describe('buildPayload', () => {expect(out.line).toBe(1);expect(out.column).toBe(1);});++ it('does not throw on the global-error path when error.stack is a non-serializable value (BigInt)', () => {+ const err = new Error('boom');+ err.stack = 1n;+ expect(() => buildPayload({+ type: 'error',+ error: err,+ message: 'boom',+ filename: 'foo.js',+ lineno: 1,+ colno: 1,+ })).not.toThrow();+ });++ it('reportClientError resolves cleanly even when JSON.stringify would throw (BigInt stack)', async () => {+ const err = new Error('boom');+ err.stack = 1n;+ const result = await reportClientError({+ type: 'error',+ error: err,+ message: 'boom',+ filename: 'foo.js',+ lineno: 1,+ colno: 1,+ });+ // safeBody falls back to a degraded payload that is still POST-able, so+ // the request goes through. The point of the test is that this resolves+ // (no synchronous throw, no rejected promise) regardless of `sent`.+ expect(typeof result.sent).toBe('boolean');+ expect(globalThis.fetch).toHaveBeenCalledTimes(1);+ const body = JSON.parse(globalThis.fetch.mock.calls[0][1].body);+ expect(body.stack === '[unserializable]' || typeof body.stack === 'string').toBe(true);+ });});describe('reportClientError', () => {