algoliasearch-client-javascript icon indicating copy to clipboard operation
algoliasearch-client-javascript copied to clipboard

Extremely large timeouts trigger immediately

Open Haroenv opened this issue 3 years ago • 0 comments

see: https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values

approximate reproduction:

  const client = getAlgoliaClient(applicationData, {
    queryParameters: userId ? { 'X-Algolia-UserID': userId } : undefined,
    timeouts: {
      connect: 2,
      read: 3600000,
      write: 3600000,
    },
  });

solution:

  1. calculate max timeout (using https://github.com/algolia/algoliasearch-client-javascript/blob/fec87a93f7642b3887507a836fb0b5800bdf56c2/packages/transporter/src/concerns/createRetryableOptions.ts#L41 with the largest number * 1000)
  2. when transporter gets created, error when timeout is larger than 2147483647/0x7FFFFFFF/2^31-1

Haroenv avatar May 21 '21 08:05 Haroenv