Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🚦 fix: Stop Queued Lookups After the First Concurrent Failure (#17557)
Marco Beretta01211053f514
diff --git a/packages/api/src/utils/promise.spec.ts b/packages/api/src/utils/promise.spec.tsindex 6ca7ef8902..5accc52941 100644--- a/packages/api/src/utils/promise.spec.ts+++ b/packages/api/src/utils/promise.spec.ts@@ -338,4 +338,20 @@ describe('mapWithConcurrency', () => {}),).rejects.toThrow('boom');});++ it('does not start queued work after a failure', async () => {+ const started: number[] = [];+ await expect(+ mapWithConcurrency([1, 2, 3, 4, 5], 2, async (value) => {+ started.push(value);+ await tick(5);+ if (value === 1) {+ throw new Error('boom');+ }+ return value;+ }),+ ).rejects.toThrow('boom');+ await tick(40);+ expect(started).toEqual([1, 2]);+ });});diff --git a/packages/api/src/utils/promise.ts b/packages/api/src/utils/promise.tsindex 7c4b0974fb..3201813ea0 100644--- a/packages/api/src/utils/promise.ts+++ b/packages/api/src/utils/promise.ts@@ -110,7 +110,8 @@ export function createConcurrencyLimiter(/*** Maps `items` through `fn` with at most `concurrency` calls in flight.* Results keep input order. The first rejection rejects the whole call, like- * `Promise.all`; calls already started are not cancelled.+ * `Promise.all`, and calls still queued are never started; calls already+ * running are not cancelled.*/export function mapWithConcurrency<T, R>(items: readonly T[],@@ -118,5 +119,20 @@ export function mapWithConcurrency<T, R>(fn: (item: T, index: number) => Promise<R>,): Promise<R[]> {const limit = createConcurrencyLimiter(concurrency);- return Promise.all(items.map((item, index) => limit(() => fn(item, index))));+ let failure: { error: unknown } | undefined;+ return Promise.all(+ items.map((item, index) =>+ limit(async () => {+ if (failure) {+ throw failure.error;+ }+ try {+ return await fn(item, index);+ } catch (error) {+ failure ??= { error };+ throw error;+ }+ }),+ ),+ );}