mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-18 22:33:08 +00:00
Fix dev server hang by reducing log spam and event frequency (#828)
* Changes from fix/dev-server-hang * fix: Address PR #828 review feedback - Reset RAF buffer on context changes (worktree switch, dev-server restart) to prevent stale output from flushing into new sessions - Fix high-frequency WebSocket filter to catch auto-mode:event wrapping (auto_mode_progress is wrapped in auto-mode:event) and add feature:progress - Reorder Vite aliases so explicit jsx-runtime entries aren't shadowed by the broad /^react(\/|$)/ regex (Vite uses first-match-wins) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: Batch dev server logs and fix React module resolution order * feat: Add fallback timer for flushing dev server logs in background tabs --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -598,24 +598,23 @@ wss.on('connection', (ws: WebSocket) => {
|
||||
|
||||
// Subscribe to all events and forward to this client
|
||||
const unsubscribe = events.subscribe((type, payload) => {
|
||||
logger.info('Event received:', {
|
||||
// Use debug level for high-frequency events to avoid log spam
|
||||
// that causes progressive memory growth and server slowdown
|
||||
const isHighFrequency =
|
||||
type === 'dev-server:output' || type === 'test-runner:output' || type === 'feature:progress';
|
||||
const log = isHighFrequency ? logger.debug.bind(logger) : logger.info.bind(logger);
|
||||
|
||||
log('Event received:', {
|
||||
type,
|
||||
hasPayload: !!payload,
|
||||
payloadKeys: payload ? Object.keys(payload) : [],
|
||||
wsReadyState: ws.readyState,
|
||||
wsOpen: ws.readyState === WebSocket.OPEN,
|
||||
});
|
||||
|
||||
if (ws.readyState === WebSocket.OPEN) {
|
||||
const message = JSON.stringify({ type, payload });
|
||||
logger.info('Sending event to client:', {
|
||||
type,
|
||||
messageLength: message.length,
|
||||
sessionId: (payload as Record<string, unknown>)?.sessionId,
|
||||
});
|
||||
ws.send(message);
|
||||
} else {
|
||||
logger.info('WARNING: Cannot send event, WebSocket not open. ReadyState:', ws.readyState);
|
||||
logger.warn('Cannot send event, WebSocket not open. ReadyState:', ws.readyState);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -88,9 +88,13 @@ const PORT_PATTERNS: Array<{ pattern: RegExp; description: string }> = [
|
||||
},
|
||||
];
|
||||
|
||||
// Throttle output to prevent overwhelming WebSocket under heavy load
|
||||
const OUTPUT_THROTTLE_MS = 4; // ~250fps max update rate for responsive feedback
|
||||
const OUTPUT_BATCH_SIZE = 4096; // Smaller batches for lower latency
|
||||
// Throttle output to prevent overwhelming WebSocket under heavy load.
|
||||
// 100ms (~10fps) is sufficient for readable log streaming while keeping
|
||||
// WebSocket traffic manageable. The previous 4ms rate (~250fps) generated
|
||||
// up to 250 events/sec which caused progressive browser slowdown from
|
||||
// accumulated console logs, JSON serialization overhead, and React re-renders.
|
||||
const OUTPUT_THROTTLE_MS = 100; // ~10fps max update rate
|
||||
const OUTPUT_BATCH_SIZE = 8192; // Larger batches to compensate for lower frequency
|
||||
|
||||
export interface DevServerInfo {
|
||||
worktreePath: string;
|
||||
|
||||
Reference in New Issue
Block a user