-
Notifications
You must be signed in to change notification settings - Fork 15
Audit and remove process.exit() calls from commands and command handlers #794
Description
Summary
Command handlers use process.exit() throughout, which causes two problems:
-
Telemetry bug (immediate):
process.exit()kills the process before PostHog's async HTTP requests complete, causing telemetry events (especiallyloom.finished) to be silently dropped. A workaround of callingTelemetryService.getInstance().shutdown()before each exit has been added incli.ts, but it's fragile and easy to forget. -
Reusability (future): Commands should be callable directly by other wrappers (e.g., a VS Code extension) without
process.exit()terminating the host process.
Affected files
src/cli.ts — ~10 process.exit(0) calls in command action handlers (workaround shutdown calls added)
src/commands/finish.ts:185 — process.exit(1) in checkForChildLooms
src/commands/start.ts:311 — process.exit(0)
src/commands/contribute.ts:238 — process.exit(0)
src/commands/update.ts — multiple process.exit(1) and process.exit(code ?? 0)
Task
- Remove all
process.exit(0)calls from command action handlers incli.ts— let commands return naturally so the top-levelprogram.parseAsync()flow handles shutdown - Remove all
process.exit()calls from command classes — commands should throw errors or return, never exit - Convert
process.exit(1)error paths to thrown errors, letting the top-level catch handle exit codes - Handle special exit codes (e.g., 130 for
UserAbortedCommitError) via typed errors with exit code properties - Remove the
TelemetryService.shutdown()workaround calls once exits are removed - Verify no open handles prevent clean process exit after commands complete
- Update tests that mock
process.exitbehavior
Metadata
Metadata
Assignees
Labels
Type
Projects
Status