fix: avoid premature psd parse timeout
This commit is contained in:
parent
ea1bc4c78b
commit
caf9eb7290
@ -25,6 +25,7 @@ import { failTimedOutAgentPsdTemplates } from "@/lib/agents/psd-template-timeout
|
||||
import { uploadFile } from "@/lib/storage/service";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
export const maxDuration = 1800;
|
||||
|
||||
function jsonError(status: number, error: string) {
|
||||
const payload: AgentPsdTemplateMutationResponse = {
|
||||
@ -291,6 +292,13 @@ export async function POST(
|
||||
});
|
||||
}
|
||||
|
||||
await updateParseProgress({
|
||||
templateId: id,
|
||||
updatedBy: session.user.id,
|
||||
progress: 24,
|
||||
stage: "正在解析 PSD 图层结构与预览",
|
||||
error: undefined,
|
||||
});
|
||||
const parsedTemplate = await parsePsdTemplateFile(fileBuffer);
|
||||
|
||||
if (parsedTemplate.layers.length === 0) {
|
||||
@ -301,7 +309,7 @@ export async function POST(
|
||||
templateId: id,
|
||||
updatedBy: session.user.id,
|
||||
progress: 42,
|
||||
stage: "正在生成模板预览",
|
||||
stage: "正在上传模板预览",
|
||||
error: undefined,
|
||||
});
|
||||
|
||||
|
||||
@ -7,8 +7,19 @@ import {
|
||||
} from "@/lib/agents/psd-template-config";
|
||||
import { readAgentPsdTemplates } from "@/lib/agents/psd-template-settings";
|
||||
|
||||
export const AGENT_PSD_TEMPLATE_QUICK_PARSE_TIMEOUT_MS = 8 * 60 * 1000;
|
||||
export const AGENT_PSD_TEMPLATE_ASSET_BACKFILL_TIMEOUT_MS = 20 * 60 * 1000;
|
||||
function getEnvPositiveInt(name: string, fallback: number) {
|
||||
const parsed = Number.parseInt(process.env[name] || "", 10);
|
||||
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
||||
}
|
||||
|
||||
export const AGENT_PSD_TEMPLATE_QUICK_PARSE_TIMEOUT_MS = getEnvPositiveInt(
|
||||
"AGENT_PSD_TEMPLATE_QUICK_PARSE_TIMEOUT_MS",
|
||||
15 * 60 * 1000
|
||||
);
|
||||
export const AGENT_PSD_TEMPLATE_ASSET_BACKFILL_TIMEOUT_MS = getEnvPositiveInt(
|
||||
"AGENT_PSD_TEMPLATE_ASSET_BACKFILL_TIMEOUT_MS",
|
||||
20 * 60 * 1000
|
||||
);
|
||||
|
||||
function getTemplateUpdatedAtTime(template: AgentPsdTemplate) {
|
||||
const updatedAt = new Date(template.updatedAt).getTime();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user