mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-04 14:39:42 +02:00
fix: add server-side crash breadcrumbs and remove --drop:console from build
The --drop:console esbuild flag was silently stripping all diagnostic console.* calls from production builds, making crash investigation impossible. Remove it temporarily for debugging. Add server-side crash breadcrumb collection: - Frontend writes breadcrumbs to localStorage AND POSTs to /api/crash-diag - Server stores latest breadcrumbs in memory, readable via GET /api/crash-diag - Granular breadcrumbs in selectSession: CACHE_WRITE, FETCH_START, FETCH_DONE, REWRITE, FOCUS, SELECT_DONE - 2s heartbeat beacon so breadcrumbs survive tab freezes - text/plain content-type parser for navigator.sendBeacon compatibility Initial findings from breadcrumbs: - Crash happens during selectSession() for sessions with large buffers - Pattern: cached buffer exists from prior visit + live SSE data arriving - Backend is always stable (0 crashes); this is a pure frontend issue Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -630,6 +630,30 @@ export class WebServer extends EventEmitter {
|
||||
}
|
||||
});
|
||||
|
||||
// Crash diagnostics beacon — frontend POSTs breadcrumbs, GET to read them
|
||||
let _crashBreadcrumbs = '';
|
||||
this.app.addContentTypeParser('text/plain;charset=UTF-8', { parseAs: 'string' }, (_req, body, done) => {
|
||||
try {
|
||||
done(null, JSON.parse(body as string));
|
||||
} catch {
|
||||
done(null, { data: body });
|
||||
}
|
||||
});
|
||||
this.app.addContentTypeParser('text/plain', { parseAs: 'string' }, (_req, body, done) => {
|
||||
try {
|
||||
done(null, JSON.parse(body as string));
|
||||
} catch {
|
||||
done(null, { data: body });
|
||||
}
|
||||
});
|
||||
this.app.post('/api/crash-diag', (req, reply) => {
|
||||
_crashBreadcrumbs = String((req.body as { data?: string })?.data || '');
|
||||
reply.code(204).send();
|
||||
});
|
||||
this.app.get('/api/crash-diag', (_req, reply) => {
|
||||
reply.code(200).send({ breadcrumbs: _crashBreadcrumbs, timestamp: Date.now() });
|
||||
});
|
||||
|
||||
// Register all route modules
|
||||
const ctx = this.createRouteContext();
|
||||
registerPushRoutes(this.app, ctx);
|
||||
|
||||
Reference in New Issue
Block a user