perf: offload SWF→Nitro conversion to a worker-thread pool
CI / check (push) Successful in 34s
CI / release (push) Skipped
CI / deploy (push) Successful in 1m0s

The synchronous convertSwfToNitro / extractIconFromSwf calls (pure CPU,
no DB/network) now run in a small worker pool so the main Node event
loop stays free during imports — the dominant import-time CPU spike is
moved off the request thread. The pool degrades gracefully to a
synchronous fallback if workers can't be created, and is skipped in the
test environment.
This commit is contained in:
openhands committed 2026-08-24 19:02:19 +02:00
1 parent 7116f49e2b
commit 8d1b09f151
6 files changed
+240 -14

No files matched your search

+14 -4
View File
@@ -24,10 +24,20 @@ vi.mock("@/lib/services/import/core/download", () => ({
validateSwfBytes: vi.fn(),
}));
vi.mock("@/lib/services/swf-to-nitro", () => ({
convertSwfToNitro: vi.fn(),
extractIconFromSwf: vi.fn(),
}));
vi.mock("@/lib/services/swf-to-nitro", () => {
const convertSwfToNitro = vi.fn();
const extractIconFromSwf = vi.fn();
return {
convertSwfToNitro,
extractIconFromSwf,
convertSwfToNitroAsync: vi.fn(async (buffer: Buffer, classname: string) =>
convertSwfToNitro(buffer, classname),
),
extractIconFromSwfAsync: vi.fn(async (buffer: Buffer, classname: string) =>
extractIconFromSwf(buffer, classname),
),
};
});
import {
autoPriceFurni,