Skip to content

Extract backend startup readiness coordination#2133

Merged
juliusmarminge merged 1 commit intomainfrom
t3code/backend-readiness-leak
Apr 17, 2026
Merged

Extract backend startup readiness coordination#2133
juliusmarminge merged 1 commit intomainfrom
t3code/backend-readiness-leak

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Apr 17, 2026

Summary

  • Extract backend startup readiness orchestration into backendStartupReadiness.ts to centralize the race between the backend listening signal and HTTP readiness probe.
  • Preserve the cancellation path so an early listening signal still aborts the HTTP wait cleanly.
  • Update desktop bootstrap logging to record which readiness source won.
  • Add unit coverage for the startup readiness helper, including fallback, listening-first, and failure cases.

Testing

  • bun run test for apps/desktop/src/backendStartupReadiness.test.ts
  • Not run: bun fmt
  • Not run: bun lint
  • Not run: bun typecheck

Note

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 waitForBackendStartupReady helper 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 (listening vs http) 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 waitForBackendStartupReady

  • Moves the backend readiness race logic from main.ts into a standalone waitForBackendStartupReady utility in backendStartupReadiness.ts, covered by a new test suite.
  • The utility races an optional listeningPromise against an HTTP readiness probe, resolves with whichever wins ("listening" or "http"), and cancels the HTTP probe when the listening signal arrives first.
  • Late HTTP rejections caused by an intentional abort are suppressed if the promise is already settled; other rejections propagate normally.
  • In the development bootstrap path, main.ts now calls waitForBackendWindowReady (instead of waitForBackendHttpReady directly) and logs the winning readiness source.

Macroscope summarized afed1d7.

- Factor HTTP/listening readiness coordination into a shared helper
- Log which signal made the desktop backend ready
- Add tests for the startup readiness flow
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eace66fe-d0ee-401b-b5a1-ca9546b8a5f3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/backend-readiness-leak

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Apr 17, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp bot commented Apr 17, 2026

Approvability

Verdict: 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.

@juliusmarminge juliusmarminge merged commit 4000973 into main Apr 17, 2026
12 checks passed
@juliusmarminge juliusmarminge deleted the t3code/backend-readiness-leak branch April 17, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant