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:
Wroclaw 2023-08-22 21:22:18 +02:00
parent 1205eea7af
commit 0931fe103d

View file

@ -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);
}