fix: reduce import concurrency to prevent 100% CPU during SWF→Nitro conversion
CI / check (push) Successful in 42s
CI / release (push) Skipped
CI / deploy (push) Successful in 1m43s

- Default batch concurrency: 3→1 (max 5→3)
- Default batch-regen concurrency: 3→1 (max 5→3)
- Default IMPORT_BATCH_CONCURRENCY: 12→3
- Added setImmediate yields between items to prevent event loop blocking

Fixes gatje and other complex furniture imports consuming 100% CPU and stalling the catalog studio.
This commit is contained in:
openhands committed 2026-08-23 19:51:04 +02:00
1 parent c043af318b
commit c2e61dc324
3 files changed
+7 -3

No files matched your search

+3 -1
View File
@@ -48,7 +48,7 @@ import type { ImportSingleResult } from "@/types/furni";
// How many items to import concurrently in a batch. The per-item work is
// network-bound (asset downloads) and DB-bound, so a modest pool gives a large
// speedup over the old fully sequential loop without overwhelming the DB.
const IMPORT_BATCH_CONCURRENCY = 12;
const IMPORT_BATCH_CONCURRENCY = 3;
async function runWithConcurrency<T, R>(
items: T[],
@@ -64,6 +64,7 @@ async function runWithConcurrency<T, R>(
const i = cursor++;
if (i >= items.length) break;
out[i] = await fn(items[i]);
await new Promise((r) => setImmediate(r));
}
},
);
@@ -849,6 +850,7 @@ export const PATCH = withAdmin(
warning: (err as Error).message,
});
}
await new Promise((r) => setImmediate(r));
}
const succeeded = results.filter((r) => r.ok).length;