Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2026-05-06 - Parallelizing fallback sequences trades network for latency
**Learning:** Converting sequential `for...of` retry/fallback loops into parallel `Promise.all` queries executes all options concurrently. While this achieves the lowest possible latency for the function, it generates redundant HTTP requests to secondary pathways if the primary succeeds.
**Action:** For internal or gateway endpoints where minimal latency is favored over network overhead (like ZimaOS local probes), `Promise.all` is beneficial. Ensure to iterate correctly through the results array in the original order to preserve state variables dependent on sequence.
4 changes: 2 additions & 2 deletions src/lib/forge-openai-surface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ 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);
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;
Expand Down