Wait some time before retrying an OpenAI request
OpenAI recommended prectice is to wait some time before retrying the request that ended with http 5xx code the bot was not doing that before, now it does this might fix some issues when we were retrying the request too fast
This commit is contained in:
parent
1205eea7af
commit
0931fe103d
1 changed files with 1 additions and 0 deletions
|
@ -349,6 +349,7 @@ async function executeFromQueue(channel: string) {
|
|||
else errorText = "";
|
||||
if (Axios.isAxiosError(e) && e.code?.match(/^5..$/) && channelQueue.tries < 3) {
|
||||
channelQueue.tries++;
|
||||
await new Promise(r => setTimeout(r, 2000)); // pause for 2 seconds before retrying
|
||||
return executeFromQueue(channel);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue