Skip to content

fix(hub): log fatal errors and exit so the supervisor restarts the hub - #175

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-12103-log-the-hubs-fatal-errors-and-restart-it-instead-of-leaving
Nov 4, 2026
Merged

TheGreatAxios merged 2 commits into
mainfrom
cl-12103-log-the-hubs-fatal-errors-and-restart-it-instead-of-leaving

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Closes CL-12103

The hub now handles unhandled rejections and uncaught exceptions: it logs them through its logger with only the error code, type and in-repo locations, runs its shutdown once, and exits with code 1. A failing shutdown step is logged and marks the exit non-zero instead of rejecting, and the startup failure log uses the same safe metadata instead of the raw error. The hub service in deploy/compose.yml gets restart: unless-stopped so Compose brings it back; the sidecar is spawned by the hub and has no service of its own there.

Verified by running apps/hub/src/server.ts with a preloaded script that rejects or throws an error carrying a database URL with a password. Before the change Bun printed the raw error with the password and the startup log carried the raw error; after it the process exits 1 with one logger line and no password, repeated several times. Lint, format check, typecheck, tests, pins:verify and vendor:verify pass.

@linear-code

linear-code Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

CL-12103

CL-12159

@TheGreatAxios
TheGreatAxios marked this pull request as ready for review November 4, 2026 22:40

@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:18-27 iife: Immediately invoked function; name the function.

@TheGreatAxios
TheGreatAxios force-pushed the cl-12103-log-the-hubs-fatal-errors-and-restart-it-instead-of-leaving branch from 4373b96 to 3a407b8 Compare November 4, 2026 22:54
@TheGreatAxios

Copy link
Copy Markdown
Contributor Author

Fixed in 3a407b8: the shutdown IIFE in apps/hub/src/server.ts is now a named shutDown function that stop calls once, with the same behaviour. Also rebased onto main.

@corbits-triage

corbits-triage Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Merged before Triage finished on 3a407b8.

@TheGreatAxios
TheGreatAxios merged commit 947975e into main Nov 4, 2026
9 checks passed
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