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

fix: allow numRetries = 0 #230

Merged
merged 2 commits into from
Oct 3, 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
8 changes: 5 additions & 3 deletions src/Typesense/ApiCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,11 @@ export default class ApiCall {
}"`,
);
// this.logger.debug(error.stack)
this.logger.warn(
`Request #${requestNumber}: Sleeping for ${this.retryIntervalSeconds}s and then retrying request...`,
);
if (numTries < this.numRetriesPerRequest + 1) {
jasonbosco marked this conversation as resolved.
Show resolved Hide resolved
this.logger.warn(
`Request #${requestNumber}: Sleeping for ${this.retryIntervalSeconds}s and then retrying request...`,
);
}
await this.timer(this.retryIntervalSeconds);
} finally {
if (abortSignal && abortListener) {
Expand Down
6 changes: 3 additions & 3 deletions src/Typesense/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ export default class Configuration {
options.connectionTimeoutSeconds || options.timeoutSeconds || 5;
this.healthcheckIntervalSeconds = options.healthcheckIntervalSeconds || 60;
this.numRetries =
options.numRetries ||
this.nodes.length + (this.nearestNode == null ? 0 : 1) ||
3;
(options.numRetries !== undefined && options.numRetries >= 0
? options.numRetries
: this.nodes.length + (this.nearestNode == null ? 0 : 1)) || 3;
this.retryIntervalSeconds = options.retryIntervalSeconds || 0.1;

this.apiKey = options.apiKey;
Expand Down
Loading