compare silently accepts invalid --timeout values
Describe the bug
compare silently accepts invalid --timeout values. parseCompareArgs converts abc to the default 5000 ms and passes -1 through as a timeout. The same command rejects invalid --cols and --at values with a usage error.
The cause is the Number.parseInt(...) || DEFAULT_RENDER_READY_TIMEOUT_MS expression in compare.ts.
Minimal reproduction
The relevant calls to the exported parser are:
import { parseCompareArgs } from "./packages/cli/src/commands/compare.ts";
for (const timeout of ["1000", "abc", "-1"]) {
const parsed = parseCompareArgs({ _: ["./a", "./b"], timeout }, "/tmp");
console.log(timeout, parsed.timeoutMs);
}
No composition assets are needed for argument parsing. I reproduced these results by executing the parser functions extracted from the linked source with the original path and error helpers. I have not run an end-to-end compare capture.
Steps to reproduce
- Evaluate the parser calls above against the linked revision after the normal repository setup.
- Compare the results for a valid timeout, non-numeric input, and a negative value.
Expected behavior
Non-numeric and negative timeout values produce a usage error before capture starts. Omitting the option keeps the 5000 ms default; valid positive integer values are preserved.
Actual behavior
| Input | timeoutMs |
Usage error |
|---|---|---|
| omitted | 5000 | no |
1000 |
1000 | no |
abc |
5000 | no |
-1 |
-1 | no |
Environment
main:124591a9d5d54fb90ab9ab832ced2b3af1527d11- Node.js 24.16.0, macOS
- Parser-only reproduction; Chrome, FFmpeg, and
hyperframes doctorwere not run.
Additional context
James confirmed this contribution direction in the CS146S HeyGen Slack. I plan to work on the validation and regression tests for my CS146S contribution. Proposed scope: packages/cli/src/commands/compare.ts, its existing test file, and relevant CLI documentation. Other timeout input formats are outside this report's proposed scope.
Taking this: parseCompareArgs should reject non-numeric and negative --timeout with the same usage error as --cols and --at, while valid values keep their current behavior. I will add the parser test and open a small PR.
Hi @Ethereal49, I opened this issue for my Stanford CS146S coursework, and James Russo has already approved the contribution. I’ve already taken it on, as noted in the issue description. Sorry for the confusion. Could you please leave this one with me to avoid duplicate work? Thanks!
Understood — withdrawing my claim. #7545 is yours; I will not open a competing PR.