feat(web): classify and route complete Blender inventory
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user