Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 4715645

Browse files
roomotehannesrudolph
authored andcommitted
fix: use task stored API config as fallback for rate limit
When provider state is unavailable (state is undefined/null), fall back to the task's stored apiConfiguration for rate limiting instead of defaulting to 0. This prevents rate limiting from being silently disabled in edge cases where getState() fails or provider reference is temporarily lost. Changes: - Line 3643 (attemptApiRequest): Use (apiConfiguration ?? this.apiConfiguration) - Line 3974 (backoffAndAnnounce): Use (state?.apiConfiguration ?? this.apiConfiguration) Both locations now follow the same pattern: 1. Prefer the most up-to-date config from provider state 2. Fall back to task's stored config if state unavailable 3. Only default to 0 if neither source has a config
1 parent 7552581 commit 4715645

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/core/task/Task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4242,7 +4242,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
42424242

42434243
// Respect provider rate limit window
42444244
let rateLimitDelay = 0
4245-
const rateLimit = state?.apiConfiguration?.rateLimitSeconds || 0
4245+
const rateLimit = (state?.apiConfiguration ?? this.apiConfiguration)?.rateLimitSeconds || 0
42464246
if (Task.lastGlobalApiRequestTime && rateLimit > 0) {
42474247
const elapsed = performance.now() - Task.lastGlobalApiRequestTime
42484248
rateLimitDelay = Math.ceil(Math.min(rateLimit, Math.max(0, rateLimit * 1000 - elapsed) / 1000))

0 commit comments

Comments
 (0)