Skip to content

Commit 9cedf39

Browse files
fix(javascript): increase default retry max (generated)
algolia/api-clients-automation#6278 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com>
1 parent 84897e7 commit 9cedf39

4 files changed

Lines changed: 18 additions & 14 deletions

File tree

packages/client-search/model/clientMethodProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ export type BrowseOptions<T> = Partial<Pick<CreateIterablePromise<T>, 'validate'
741741

742742
type WaitForOptions = Partial<{
743743
/**
744-
* The maximum number of retries. 50 by default.
744+
* The maximum number of retries. 100 by default.
745745
*/
746746
maxRetries: number;
747747

packages/client-search/src/searchClient.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ export function createSearchClient({
251251
* @param waitForTaskOptions - The `waitForTaskOptions` object.
252252
* @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
253253
* @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
254-
* @param waitForTaskOptions.maxRetries - The maximum number of retries. 50 by default.
254+
* @param waitForTaskOptions.maxRetries - The maximum number of retries. 100 by default.
255255
* @param waitForTaskOptions.timeout - The function to decide how long to wait between retries.
256256
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
257257
*/
258258
waitForTask(
259259
{
260260
indexName,
261261
taskID,
262-
maxRetries = 50,
262+
maxRetries = 100,
263263
timeout = (retryCount: number): number => Math.min(retryCount * 200, 5000),
264264
}: WaitForTaskOptions,
265265
requestOptions?: RequestOptions | undefined,
@@ -272,7 +272,8 @@ export function createSearchClient({
272272
aggregator: () => (retryCount += 1),
273273
error: {
274274
validate: () => retryCount >= maxRetries,
275-
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
275+
message: () =>
276+
`Stopped waiting for the task after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`,
276277
},
277278
timeout: () => timeout(retryCount),
278279
});
@@ -284,14 +285,14 @@ export function createSearchClient({
284285
* @summary Helper method that waits for a task to be published (completed).
285286
* @param waitForAppTaskOptions - The `waitForTaskOptions` object.
286287
* @param waitForAppTaskOptions.taskID - The `taskID` returned in the method response.
287-
* @param waitForAppTaskOptions.maxRetries - The maximum number of retries. 50 by default.
288+
* @param waitForAppTaskOptions.maxRetries - The maximum number of retries. 100 by default.
288289
* @param waitForAppTaskOptions.timeout - The function to decide how long to wait between retries.
289290
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
290291
*/
291292
waitForAppTask(
292293
{
293294
taskID,
294-
maxRetries = 50,
295+
maxRetries = 100,
295296
timeout = (retryCount: number): number => Math.min(retryCount * 200, 5000),
296297
}: WaitForAppTaskOptions,
297298
requestOptions?: RequestOptions | undefined,
@@ -304,7 +305,8 @@ export function createSearchClient({
304305
aggregator: () => (retryCount += 1),
305306
error: {
306307
validate: () => retryCount >= maxRetries,
307-
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
308+
message: () =>
309+
`Stopped waiting for the task after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`,
308310
},
309311
timeout: () => timeout(retryCount),
310312
});
@@ -318,7 +320,7 @@ export function createSearchClient({
318320
* @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
319321
* @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
320322
* @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
321-
* @param waitForApiKeyOptions.maxRetries - The maximum number of retries. 50 by default.
323+
* @param waitForApiKeyOptions.maxRetries - The maximum number of retries. 100 by default.
322324
* @param waitForApiKeyOptions.timeout - The function to decide how long to wait between retries.
323325
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getApikey` method and merged with the transporter requestOptions.
324326
*/
@@ -327,7 +329,7 @@ export function createSearchClient({
327329
operation,
328330
key,
329331
apiKey,
330-
maxRetries = 50,
332+
maxRetries = 100,
331333
timeout = (retryCount: number): number => Math.min(retryCount * 200, 5000),
332334
}: WaitForApiKeyOptions,
333335
requestOptions?: RequestOptions | undefined,
@@ -337,7 +339,8 @@ export function createSearchClient({
337339
aggregator: () => (retryCount += 1),
338340
error: {
339341
validate: () => retryCount >= maxRetries,
340-
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
342+
message: () =>
343+
`Stopped waiting for the API key operation after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`,
341344
},
342345
timeout: () => timeout(retryCount),
343346
};

packages/composition/model/clientMethodProps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export type UpdateSortingStrategyCompositionProps = {
234234

235235
export type WaitForCompositionTaskOptions = {
236236
/**
237-
* The maximum number of retries. 50 by default.
237+
* The maximum number of retries. 100 by default.
238238
*/
239239
maxRetries?: number | undefined;
240240

packages/composition/src/compositionClient.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ export function createCompositionClient({
165165
* @param WaitForCompositionTaskOptions - The `WaitForCompositionTaskOptions` object.
166166
* @param WaitForCompositionTaskOptions.compositionID - The `compositionID` where the operation was performed.
167167
* @param WaitForCompositionTaskOptions.taskID - The `taskID` returned in the method response.
168-
* @param WaitForCompositionTaskOptions.maxRetries - The maximum number of retries. 50 by default.
168+
* @param WaitForCompositionTaskOptions.maxRetries - The maximum number of retries. 100 by default.
169169
* @param WaitForCompositionTaskOptions.timeout - The function to decide how long to wait between retries.
170170
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
171171
*/
172172
waitForCompositionTask(
173173
{
174174
compositionID,
175175
taskID,
176-
maxRetries = 50,
176+
maxRetries = 100,
177177
timeout = (retryCount: number): number => Math.min(retryCount * 200, 5000),
178178
}: WaitForCompositionTaskOptions,
179179
requestOptions?: RequestOptions,
@@ -186,7 +186,8 @@ export function createCompositionClient({
186186
aggregator: () => (retryCount += 1),
187187
error: {
188188
validate: () => retryCount >= maxRetries,
189-
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
189+
message: () =>
190+
`Stopped waiting for the task after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`,
190191
},
191192
timeout: () => timeout(retryCount),
192193
});

0 commit comments

Comments
 (0)