mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: correct rate limiting calculation to prevent incorrect delay display
- Fixed rate limiting logic in Task.ts to properly handle undefined lastGlobalApiRequestTime - Added check for rateLimit > 0 before applying rate limiting - Simplified calculation to only apply delay when there's actually time remaining - This prevents the incorrect '15903 seconds' message reported in issue #7770
This commit is contained in:
parent
25717817a6
commit
713e8919ea
1 changed files with 7 additions and 3 deletions
|
|
@ -2528,11 +2528,15 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
|
||||
// Use the shared timestamp so that subtasks respect the same rate-limit
|
||||
// window as their parent tasks.
|
||||
if (Task.lastGlobalApiRequestTime) {
|
||||
const rateLimit = apiConfiguration?.rateLimitSeconds || 0
|
||||
if (Task.lastGlobalApiRequestTime && rateLimit > 0) {
|
||||
const now = Date.now()
|
||||
const timeSinceLastRequest = now - Task.lastGlobalApiRequestTime
|
||||
const rateLimit = apiConfiguration?.rateLimitSeconds || 0
|
||||
rateLimitDelay = Math.ceil(Math.max(0, rateLimit * 1000 - timeSinceLastRequest) / 1000)
|
||||
const remainingDelay = rateLimit * 1000 - timeSinceLastRequest
|
||||
// Only apply rate limit if there's actually time remaining to wait
|
||||
if (remainingDelay > 0) {
|
||||
rateLimitDelay = Math.ceil(remainingDelay / 1000)
|
||||
}
|
||||
}
|
||||
|
||||
// Only show rate limiting message if we're not retrying. If retrying, we'll include the delay there.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue