feat(web): classify and route complete Blender inventory
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-09-06 21:10:31 +08:00
parent 66d3f4e0f4
commit e2e81c7c00
41 changed files with 116672 additions and 37 deletions

View File

@@ -115,3 +115,19 @@ export async function cancelServerJobProcess(handle, cleanup, options = {}) {
handle.receipt.orphanCount = treeExited ? 0 : 1;
return Object.freeze({ ...result, treeSignal: handle.receipt.treeSignal, cleanupCount: handle.receipt.cleanupCount, orphanCount: handle.receipt.orphanCount });
}
export function validateServerJobBudget(options = {}) {
const timeoutMs = options.timeoutMs ?? 10 * 60 * 1000;
const maxOutputBytes = options.maxOutputBytes ?? 8 * 1024 * 1024;
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1000 || timeoutMs > 10 * 60 * 1000) invalid("timeoutMs is outside the bounded server-job budget");
if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 1024 || maxOutputBytes > 64 * 1024 * 1024) invalid("maxOutputBytes is outside the bounded server-job budget");
return Object.freeze({ timeoutMs, maxOutputBytes });
}
export function startBoundedServerJobProcess(command, args = [], options = {}) {
const budget = validateServerJobBudget(options);
const handle = startServerJobProcess(command, args, options);
const timeout = setTimeout(() => { void cancelServerJobProcess(handle, options.cleanup ?? (async () => {}), { graceMs: options.graceMs ?? 500 }); }, budget.timeoutMs);
handle.completion.finally(() => clearTimeout(timeout));
return handle;
}