From 24d8c9a7d01a7cb8dd43b18a46076dfee7c45ef2 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 12 May 2026 17:49:30 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20[performance=20improvement]?= =?UTF-8?q?=20Parallelize=20ZimaOS=20model=20fetches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parallelizes sequential fetch operations in `collectZimaOSV1ModelEntries` using `Promise.all` to significantly reduce event loop blocking and overall gateway response times. Maintains identical logical assignments for state-dependent variables by iterating over the resolved results sequentially. Co-authored-by: bobdivx <6737167+bobdivx@users.noreply.github.com> --- .jules/bolt.md | 3 +++ src/lib/forge-openai-surface.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 00000000..d646023e --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2025-05-12 - Parallelize Gateway Surface Fetching +**Learning:** In gateway surface aggregation (`src/lib/forge-openai-surface.ts`), querying multiple paths sequentially with await blocks the event loop on I/O. +**Action:** Use `Promise.all` to fetch parallel paths for API routes, iterating through the returned results array sequentially afterward to maintain state-dependent side effects exactly identical to the original behavior (such as `lastStatus` and `lastRaw`). \ No newline at end of file diff --git a/src/lib/forge-openai-surface.ts b/src/lib/forge-openai-surface.ts index 93415262..127315b2 100644 --- a/src/lib/forge-openai-surface.ts +++ b/src/lib/forge-openai-surface.ts @@ -118,8 +118,12 @@ export async function collectZimaOSV1ModelEntries( let lastError: string | undefined; let lastRaw: unknown = null; - for (const path of V1_MODELS_PATHS) { - const r = await fetchZimaOSJson(email, path); + // ⚡ Bolt: Parallelized sequential fetch operations for faster gateway response + const results = await Promise.all( + V1_MODELS_PATHS.map((path) => fetchZimaOSJson(email, path)) + ); + + for (const r of results) { lastStatus = r.status; lastError = r.error; lastRaw = r.data;