mirror of
https://github.com/laurent22/joplin.git
synced 2026-10-25 02:47:28 +00:00
Desktop: Chat panel: Fix rate limit handling (#16031)
This commit is contained in:
1 parent
8cd4502472
commit
87f82bb8fb
1 file changed
+4
-2
@@ -61,9 +61,11 @@ export const mapErrorByCode = (code: string | number | null, status: number, det
|
|||||||
// For now, avoid more than one event every second or two.
|
// For now, avoid more than one event every second or two.
|
||||||
const minimumTimeBetweenEvents = Second;
|
const minimumTimeBetweenEvents = Second;
|
||||||
|
|
||||||
type ApiError = Error & { code?: number; retryAfterSeconds?: number };
|
type ApiError = Error & { code?: number|string; retryAfterSeconds?: number };
|
||||||
|
|
||||||
const isRateLimitError = (error: ApiError) => error.code === 429 && typeof error.retryAfterSeconds === 'number';
|
const isRateLimitError = (error: ApiError) => (
|
||||||
|
(error.code === 429 || error.code === 'aiRateLimitExceeded') && typeof error.retryAfterSeconds === 'number'
|
||||||
|
);
|
||||||
|
|
||||||
const canAutoRetryError = (error: ApiError) => {
|
const canAutoRetryError = (error: ApiError) => {
|
||||||
return isRateLimitError(error) && error.retryAfterSeconds < 10;
|
return isRateLimitError(error) && error.retryAfterSeconds < 10;
|
||||||
|
|||||||
Reference in new issue
Block a user