()
| 48 | } |
| 49 | |
| 50 | // Process the request queue with rate limit awareness |
| 51 | async processQueue() { |
| 52 | if (this.processingQueue || this.requestQueue.length === 0) { |
| 53 | return; |
| 54 | } |
| 55 | |
| 56 | this.processingQueue = true; |
| 57 | |
| 58 | while (this.requestQueue.length > 0) { |
| 59 | const request = this.requestQueue.shift(); |
| 60 | |
| 61 | try { |
| 62 | // Check rate limit before making request |
| 63 | await this.checkRateLimit(); |
| 64 | |
| 65 | const response = await this.makeRequestWithRetry(request.url, request.options); |
| 66 | this.updateRateLimitInfo(response); |
| 67 | request.resolve(response); |
| 68 | |
| 69 | // Small delay between requests to be respectful |
| 70 | await this.delay(100); |
| 71 | |
| 72 | } catch (error) { |
| 73 | request.reject(error); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | this.processingQueue = false; |
| 78 | } |
| 79 | |
| 80 | // Check rate limit and wait if necessary |
no test coverage detected