Skip to content

[Reliability] Uncaught rejections in history/config/batch commands print raw stack traces #272

Description

@404-Page-Found

Summary

The history, config, and batch command handlers call loadConfig()/loadRawConfig()/countEntries() outside any try/catch, and src/index.ts action handlers don't wrap them. A corrupted config.json (which loadConfig deliberately surfaces as an error) or an unreadable history file triggers an unhandled promise rejection that prints a raw Node stack trace — instead of the friendly outro(pc.red(...)) error UI used elsewhere (e.g. suggest.ts).

Location

  • src/commands/history.ts:23 (in getHistoryJsonOutput), :50 (in historyCommand) — loadConfig() unguarded
  • src/commands/config.ts:192 (loadConfig()), :230 (loadRawConfig()) — unguarded
  • src/commands/batch.tsloadOrPromptConfig() unguarded
  • src/index.ts:105-185 — action handlers have no shared error boundary

Code snippet

// src/commands/history.tsconstconfig=awaitloadConfig();// throws on invalid JSON in config.json → unhandled rejectionconsttotal=awaitcountEntries();

Suggested fix

Add a shared error boundary for command handlers, e.g. a runCli(fn) helper in src/index.ts that catches and renders outro(pc.red(message)) and sets process.exitCode = 1 — or register a process.on('unhandledRejection') handler that renders the friendly error consistently.

Impact

  • Expected error conditions (corrupted config/history files) crash with full stack traces, which look like bugs to end users.
  • UX is inconsistent: the same corrupted-config error is friendly in suggest but a raw trace in history/config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions