MCPcopy Create free account
hub / github.com/openai/openai-node / shouldRetry

Method shouldRetry

src/client.ts:1028–1049  ·  view source on GitHub ↗
(response: Response)

Source from the content-addressed store, hash-verified

1026 }
1027
1028 private async shouldRetry(response: Response): Promise<boolean> {
1029 // Note this is not a standard header.
1030 const shouldRetryHeader = response.headers.get('x-should-retry');
1031
1032 // If the server explicitly says whether or not to retry, obey.
1033 if (shouldRetryHeader === 'true') return true;
1034 if (shouldRetryHeader === 'false') return false;
1035
1036 // Retry on request timeouts.
1037 if (response.status === 408) return true;
1038
1039 // Retry on lock timeouts.
1040 if (response.status === 409) return true;
1041
1042 // Retry on rate limits.
1043 if (response.status === 429) return true;
1044
1045 // Retry internal errors.
1046 if (response.status >= 500) return true;
1047
1048 return false;
1049 }
1050
1051 private async retryRequest(
1052 options: FinalRequestOptions,

Callers 1

makeRequestMethod · 0.95

Calls 1

getMethod · 0.80

Tested by

no test coverage detected