Extract backend startup readiness coordination#2133
Conversation
- Factor HTTP/listening readiness coordination into a shared helper - Log which signal made the desktop backend ready - Add tests for the startup readiness flow
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This is a mechanical refactor that extracts existing backend readiness coordination logic into a separate testable module. The extracted logic is functionally identical to what was inline, with the minor improvement that development mode bootstrap now uses the same full readiness coordination as production. New unit tests provide coverage for the extracted function. You can customize Macroscope's approvability policy. Learn more. |
Summary
backendStartupReadiness.tsto centralize the race between the backend listening signal and HTTP readiness probe.Testing
bun run testforapps/desktop/src/backendStartupReadiness.test.tsbun fmtbun lintbun typecheckNote
Low Risk
Small refactor that moves existing readiness orchestration into a helper and adds tests; behavioral changes are limited to readiness selection/cancellation and log output.
Overview
Centralizes backend startup readiness coordination into a new
waitForBackendStartupReadyhelper that races a backend listening signal against the existing HTTP readiness probe, preserving the abort/cancellation behavior when listening wins.Updates desktop bootstrap (
main.ts) to use the new helper instead of inline promise-race logic, and enhances logging to record which readiness source (listeningvshttp) determined readiness. Adds focused Vitest coverage for fallback, listening-first cancellation, and listening-failure cases.Reviewed by Cursor Bugbot for commit afed1d7. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Extract backend startup readiness coordination into
waitForBackendStartupReadymain.tsinto a standalonewaitForBackendStartupReadyutility in backendStartupReadiness.ts, covered by a new test suite.listeningPromiseagainst an HTTP readiness probe, resolves with whichever wins ("listening"or"http"), and cancels the HTTP probe when the listening signal arrives first.main.tsnow callswaitForBackendWindowReady(instead ofwaitForBackendHttpReadydirectly) and logs the winning readiness source.Macroscope summarized afed1d7.