8 months ago
c98138cEnhance server manager startup handling and add unit tests. Key changes: - Collect recent stdout lines and ignore non-JSON log lines while waiting for the server_listening JSON; include recent output in error messages when startup times out or the process exits early. - Replace single-line read with line stream handling to tolerate multi-line startup logs. - Capture a tail of stderr (limit configurable) and detect likely Bun crashes/segfaults to provide clearer error messages. - Add Windows-specific retry logic when running the server from source: create a per-attempt transpiler cache directory, retry once with async transpiler disabled if Bun crashes during startup, and perform best-effort cleanup of temp cache directories. - Track per-server cleanup functions and ensure they are invoked when servers stop or exit. - Expose internal helpers (__internal) for testing: buildSourceEnvForAttempt, isLikelyBunSegfault, waitForServerListening. - Add tests (apps/desktop/test/server-manager.test.ts) validating startup JSON parsing behavior and Bun crash detection. These changes improve resilience when running the server in development (especially on Windows with Bun) and make startup failures easier to diagnose.
Parent5e942f3