paperclipai/paperclip · error · HttpError

concurrency_limited

concurrency_limited

Error message

Too many concurrent file preview requests

What it means

Concurrency-limit rejection from the file-preview limiter's acquire: the per-key in-flight counter exceeded the concurrent preview cap while requests were still active. Thrown as HttpError 429 (code 'rate_limited') so a burst of simultaneous large previews for one key cannot exhaust the server.

Source

Thrown at server/src/routes/file-resources.ts:99

  return {
    acquire(key: string) {
      const now = Date.now();
      for (const [windowKey, existing] of windowsByKey) {
        if (now - existing.startedAt >= windowMs) windowsByKey.delete(windowKey);
      }
      const window = windowsByKey.get(key);
      if (!window || now - window.startedAt >= windowMs) {
        windowsByKey.set(key, { startedAt: now, count: 1 });
      } else {
        window.count += 1;
        if (window.count > maxRequests) {
          throw new HttpError(429, requestLimitMessage, { code: "rate_limited" });
        }
      }

      const active = activeByKey.get(key) ?? 0;
      if (active >= maxConcurrent) {
        throw new HttpError(429, concurrencyLimitMessage, { code: "concurrency_limited" });
      }
      activeByKey.set(key, active + 1);
      return () => {
        const current = activeByKey.get(key) ?? 0;
        if (current <= 1) activeByKey.delete(key);
        else activeByKey.set(key, current - 1);
      };
    },
  };
}

export function createFileResourceListLimiter(opts: {
  maxConcurrent?: number;
  maxRequests?: number;
  windowMs?: number;
} = {}): FileResourceLimiter {
  return createFileResourceLimiter({
    maxConcurrent: opts.maxConcurrent ?? 2,

View on GitHub (pinned to a7e689b3c3)

Solutions

  1. Wait for in-flight file preview requests to finish before issuing more.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/src/routes/file-resources.ts:99 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of paperclipai/paperclip@a7e689b3c3 (2026-08-18). Data as JSON: /api/errors/c892fe29620f2f20. Report an issue: GitHub.