Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: response timeout to be configurable from environment #123

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function apiRequest({method = 'GET', endpoint, json, authorize = true, ful
url: `${options.api}${endpoint}`,
responseType: 'json',
timeout: {
request: CONSTANTS.REQUEST_TIMEOUT
response: options.responseTimeout
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ program
.option('--no-ignore-dot', 'Do not ignore dotfiles in the path (`WATCHER_IGNORE_DOT=0`).')
.option('--strict-revision-check', 'For CKL, ignore checklist of uninstalled STIG revision (`WATCHER_STRICT_REVISION_CHECK=1`). Negate with `--no-strict-revision-check`.', getBoolean('WATCHER_STRICT_REVISION_CHECK', false))
.option('--no-strict-revision-check', 'For CKL, allow checklist of uninstalled STIG revision (`WATCHER_STRICT_REVISION_CHECK=0`). This is the default behavior.')
.option('--response-timeout <ms>', 'Specify the timeout duration in milliseconds for an API response to begin. If a response takes longer than this time, an error will be thrown.', parseIntegerArg, parseIntegerEnv(pe.WATCHER_RESPONSE_TIMEOUT) ?? 20000) // 20 secs

// Parse ARGV and get the parsed options object
// Options properties are created as camelCase versions of the long option name
Expand Down
6 changes: 3 additions & 3 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function getOpenIDConfiguration () {
const requestOptions = {
responseType: 'json',
timeout: {
request: CONSTANTS.REQUEST_TIMEOUT
response: options.responseTimeout
}
}
let response
Expand Down Expand Up @@ -122,7 +122,7 @@ async function authenticateClientSecret () {
password: options.clientSecret,
responseType: 'json',
timeout: {
request: CONSTANTS.REQUEST_TIMEOUT
response: options.responseTimeout
}
}

Expand Down Expand Up @@ -180,7 +180,7 @@ async function authenticateSignedJwt () {
},
responseType: 'json',
timeout: {
request: CONSTANTS.REQUEST_TIMEOUT
response: options.responseTimeout
}
}
logger.debug({
Expand Down
3 changes: 1 addition & 2 deletions lib/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ export const ERR_AUTHOFFLINE = 2
export const ERR_NOTOKEN = 3
export const ERR_NOGRANT = 4
export const ERR_UNKNOWN = 5
export const ERR_FAILINIT = 6
export const REQUEST_TIMEOUT = 5000
export const ERR_FAILINIT = 6