Skip to content

fix(hub): stop the hub when it is signalled during startup - #192

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-12159-stop-the-hub-when-it-is-signalled-during-startup
Nov 5, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
cl-12159-stop-the-hub-when-it-is-signalled-during-startup

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

A SIGTERM or SIGINT during startup is now recorded and acted on once startup finishes, so the shutdown closes what startup opened. Startup skips Bun.serve, runtime.start() and "Hub ready" once a stop has been requested. A fatal error still shuts down at once without waiting for startup, so the supervisor restarts the hub. Before, the first signal ran the shutdown with nothing to close and returned, and startup went on to bind the port and stay up.

Fixes CL-12159.

Verification

Against a real hub on throwaway Postgres databases, with SIGTERM sent once pg_stat_activity showed startup held on a tenant table lock:

Case Runs Result
Stop during startup, main 3/3 still running, port listening, "Hub ready" logged
Stop during startup, this change 3/3 exit 0, port never listening, no "Hub ready"
Stop after ready 2/2 exit 0, port closed
Fatal error during startup 2/2 exit 1 within 10 ms, logged, port never listening

No log contained a database URL. bun run lint, format:check, typecheck and test (290 pass) pass.

@linear-code

linear-code Bot commented Nov 5, 2026

Copy link
Copy Markdown

CL-12159

@TheGreatAxios
TheGreatAxios marked this pull request as draft November 5, 2026 02:38
@TheGreatAxios
TheGreatAxios marked this pull request as ready for review November 5, 2026 02:50

@corbits-triage corbits-triage Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Triage requests changes:

  • Conventions: added code matches a code pattern
    • apps/hub/src/server.ts:47 promise-chain: Promise chain; use async/await with try/catch.

A stop during startup ran the shutdown before anything existed to close, and startup then bound the port and stayed up. A stop signal during startup is now recorded and acted on once startup finishes, and startup skips binding the port when a stop is pending, so the stop closes what startup opened and the process exits. A fatal error still shuts down at once without waiting for startup.
@TheGreatAxios
TheGreatAxios force-pushed the cl-12159-stop-the-hub-when-it-is-signalled-during-startup branch from 5f68744 to b33b61a Compare November 5, 2026 02:59
@TheGreatAxios
TheGreatAxios marked this pull request as ready for review November 5, 2026 03:06
@corbits-triage

corbits-triage Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

@corbits-triage
corbits-triage Bot dismissed their stale review November 5, 2026 03:09

Nothing triage asked to change still fails, so this request no longer stands.

@corbits-triage corbits-triage Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No defects reported.

@TheGreatAxios
TheGreatAxios added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit 5700ca0 Nov 5, 2026
9 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-12159-stop-the-hub-when-it-is-signalled-during-startup branch November 5, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant