opencode-codebase-index 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3172,10 +3172,14 @@ var Indexer = class {
3172
3172
  stats.indexedChunks++;
3173
3173
  }
3174
3174
  }
3175
- const queue = new PQueue({ concurrency: 3 });
3175
+ const queue = new PQueue({ concurrency: 1, interval: 4e3, intervalCap: 1 });
3176
3176
  const dynamicBatches = createDynamicBatches(chunksNeedingEmbedding);
3177
+ let rateLimitBackoffMs = 0;
3177
3178
  for (const batch of dynamicBatches) {
3178
3179
  queue.add(async () => {
3180
+ if (rateLimitBackoffMs > 0) {
3181
+ await new Promise((resolve4) => setTimeout(resolve4, rateLimitBackoffMs));
3182
+ }
3179
3183
  try {
3180
3184
  const result = await pRetry(
3181
3185
  async () => {
@@ -3184,15 +3188,17 @@ var Indexer = class {
3184
3188
  },
3185
3189
  {
3186
3190
  retries: this.config.indexing.retries,
3187
- minTimeout: this.config.indexing.retryDelayMs,
3188
- maxTimeout: 3e4,
3191
+ minTimeout: Math.max(this.config.indexing.retryDelayMs, 5e3),
3192
+ // Minimum 5s between retries
3193
+ maxTimeout: 6e4,
3194
+ // Max 60s backoff
3189
3195
  factor: 2,
3190
3196
  onFailedAttempt: (error) => {
3191
3197
  const message = getErrorMessage(error);
3192
3198
  if (isRateLimitError(error)) {
3193
- queue.concurrency = 1;
3199
+ rateLimitBackoffMs = Math.min(6e4, (rateLimitBackoffMs || 5e3) * 2);
3194
3200
  console.error(
3195
- `Rate limited (attempt ${error.attemptNumber}/${error.retriesLeft + error.attemptNumber}): waiting before retry...`
3201
+ `Rate limited (attempt ${error.attemptNumber}/${error.retriesLeft + error.attemptNumber}): waiting ${rateLimitBackoffMs / 1e3}s before retry...`
3196
3202
  );
3197
3203
  } else {
3198
3204
  console.error(
@@ -3202,6 +3208,9 @@ var Indexer = class {
3202
3208
  }
3203
3209
  }
3204
3210
  );
3211
+ if (rateLimitBackoffMs > 0) {
3212
+ rateLimitBackoffMs = Math.max(0, rateLimitBackoffMs - 2e3);
3213
+ }
3205
3214
  const items = batch.map((chunk, idx) => ({
3206
3215
  id: chunk.id,
3207
3216
  vector: result.embeddings[idx],