fix: clean up spinner on Commander errors#41
Conversation
doistbot
left a comment
There was a problem hiding this comment.
This PR fixes the stuck early-loading spinner on Commander parse errors by adding exitOverride() and configureOutput hooks that stop the spinner before Commander writes to stdout/stderr, plus a regression test.
Few things worth tightening:
- The
configureOutputsetup is applied to the rootprogram, but the routed-command parser created inrunRoutedCommand()(e.g.tdc view <conversation-url>) gets onlyexitOverride()without the spinner-stopping output hooks — that proxy parser's unknown-option errors can still leave the spinner running. Consider extracting a shared command-output setup helper and applying it to both. - The test assertion pins Commander's exact error string (
"error: unknown option '--from'\n"), which the codebase doesn't control. A partial match likeexpect.stringContaining("--from")would be more resilient to Commander wording changes while still proving the error reached stderr.
I also included a few optional follow-up notes in the details below.
Optional follow-up note (1)
src/index.test.ts:65: This assertion pins Commander's exact error message format (
"error: unknown option '--from'\n"), which the codebase doesn't control. A Commander minor/patch that tweaks wording or punctuation would break the test even though the behavior under test (spinner stops before error output, clean exit with code 1) is still correct. The ordering assertion on line 66–68 already proves the spinner stopped before stderr was written. For the content check, a partial match would be more resilient, e.g.:ts expect(stderrWriteSpy).toHaveBeenCalledWith(expect.stringContaining("--from"))This still confirms the parse error reached stderr without coupling to Commander's exact phrasing.
|
Also addressed the optional test assertion note in c205b0f. The test now uses -- Replied by Clanker 🤖 |
|
@doistbot /review |
doistbot
left a comment
There was a problem hiding this comment.
This PR updates fix: clean up spinner on Commander errors. No issues were flagged in the reviewed diff.
nats12
left a comment
There was a problem hiding this comment.
🚀 works as expected, the loader is removed.
Summary
exitOverride()so parse/help/version exits go through normal cleanup instead of directprocess.exit().Failure scenario
Anonymized reproduction from the original report:
Before this change, Commander printed:
but the early
Loading...spinner could remain active/corrupt the terminal untilresetbecause Commander exited before the spinner cleanup path ran.Testing
npm testoxfmt,oxlint,npm run type-checknpm test