Skip to content

fix: honor options.requestTimeout in afdocs check - #175

Merged
dacharyc merged 2 commits into
mainfrom
fix/issue-169-request-timeout
Nov 29, 2026
Merged

dacharyc merged 2 commits into
mainfrom
fix/issue-169-request-timeout

Conversation

@dacharyc

Copy link
Copy Markdown
Member

Summary

Closes #169.

  • afdocs check now honors options.requestTimeout from the config file. The command built its runner options field by field and never read this one, so the CLI always used the 15000 ms default while the vitest helpers honored the configured value.
  • Adds a --request-timeout <ms> flag, which overrides the config value like the other request flags.
  • Rejects a requestTimeout of 0 in both the config loader and validateRunnerOptions. A zero timeout aborts every request immediately, so the minimum is now 1.
  • Corrects the documented default in the config file reference from 30000 to 15000 (the code default has always been 15000) and documents the new flag in the CLI reference.

Test plan

  • npx vitest run (2052 tests pass), including new CLI tests for the unset case, config passthrough, flag-over-config precedence, and rejection of --request-timeout 0
  • New validation tests for the minimum of 1
  • Type-check, ESLint and Prettier pass
  • Manual run of the built CLI against a local server that delays each response by 300 ms: requestTimeout: 1 in the config now fails the fetches, --request-timeout 5000 on top of that config lets them complete, and --request-timeout 0 exits with a validation error

The check command built its runner options field by field and never read
requestTimeout from the config file, so the CLI always used the 15000 ms
default while the vitest helpers honored the configured value.

Forward the config value, add a --request-timeout flag that overrides it,
and reject 0 in both validators, since a zero timeout aborts every request.
Correct the documented default from 30000 to 15000.

Copilot AI 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.

🟡 Changes recommended

The request-timeout parser silently truncates inputs such as 1e4 and 1.5, bypassing validation and potentially causing requests to healthy servers to fail.

1 open issue
What changed in this PR

This PR fixes #169 by wiring configured request timeouts into afdocs check, aligning the CLI with the existing runner behavior.

Changes:

  • Honors options.requestTimeout and adds a --request-timeout override.
  • Requires timeouts of at least 1 ms in config and runner validation.
  • Adds regression tests and corrects the documented default to 15000 ms.
File Description
test/​unit/​validation.test.ts Tests timeout validation at 0 and 1 ms.
test/​unit/​cli/​check-command.test.ts Tests config passthrough, flag precedence, unset behavior, and zero rejection.
src/​validation.ts Enforces the 1 ms minimum for runner options.
src/​helpers/​config.ts Enforces the same minimum in config files.
src/​cli/​commands/​check.ts Adds the timeout flag and forwards the selected value to the runner.
docs/​reference/​config-file.md Corrects the timeout default and documents the minimum.
docs/​reference/​cli.md Documents the new flag and timeout guidance.

Review effort: Balanced

Comment thread src/cli/commands/check.ts Resolved
parseInt reads only the numeric prefix, so "1e4" became a 1 ms timeout
and "1.5" passed the integer check. Convert with Number so the existing
validator sees the real value and rejects anything that is not an integer.
@dacharyc
dacharyc merged commit 1dcb51d into main Nov 29, 2026
3 checks passed
@dacharyc
dacharyc deleted the fix/issue-169-request-timeout branch November 29, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

options.requestTimeout in the config file is ignored by afdocs check

2 participants