fix: extend image task waits and scale adjust health
This commit is contained in:
parent
1ad52fd3c3
commit
e6d3b20308
@ -770,7 +770,7 @@ type DirectDetailReviewResult = {
|
||||
};
|
||||
|
||||
const AGENT_IMAGE_TASK_POLL_INTERVAL_MS = 1600;
|
||||
const AGENT_IMAGE_TASK_TIMEOUT_MS = 8 * 60 * 1000;
|
||||
const AGENT_IMAGE_TASK_TIMEOUT_MS = 20 * 60 * 1000;
|
||||
const AGENT_DETAIL_IMAGE_PARALLEL_WORKER_COUNT = 4;
|
||||
|
||||
function sleep(ms: number) {
|
||||
|
||||
@ -435,7 +435,7 @@ const CANVAS_AGENT_SECTION_TITLES = new Set([
|
||||
"输出设置",
|
||||
]);
|
||||
const CANVAS_IMAGE_TASK_POLL_INTERVAL_MS = 1600;
|
||||
const CANVAS_IMAGE_TASK_TIMEOUT_MS = 4 * 60 * 1000;
|
||||
const CANVAS_IMAGE_TASK_TIMEOUT_MS = 20 * 60 * 1000;
|
||||
const CANVAS_GENERATION_NODE_GAP = 56;
|
||||
const CANVAS_GENERATION_STACK_GAP = 28;
|
||||
const CANVAS_GENERATION_COLLISION_GAP = 32;
|
||||
|
||||
@ -37,7 +37,7 @@ export const LOCAL_EDIT_MAX_REGIONS = 8;
|
||||
export const LOCAL_EDIT_MAX_REFERENCE_IMAGES_PER_REGION = 3;
|
||||
export const LOCAL_EDIT_MIN_EDGE_PX = 24;
|
||||
export const LOCAL_EDIT_POLL_INTERVAL_MS = 2500;
|
||||
export const LOCAL_EDIT_MAX_POLL_ATTEMPTS = 192;
|
||||
export const LOCAL_EDIT_MAX_POLL_ATTEMPTS = 480;
|
||||
export const LOCAL_EDIT_COLORS = [
|
||||
"#ef4444",
|
||||
"#2563eb",
|
||||
|
||||
@ -640,8 +640,8 @@ function formatImageResponse(
|
||||
const GRSAI_NANO_BANANA_SUBMIT_TIMEOUT_MS = 30000;
|
||||
const GRSAI_NANO_BANANA_POLL_TIMEOUT_MS = 30000;
|
||||
const GRSAI_NANO_BANANA_POLL_INTERVAL_MS = 5000;
|
||||
const GRSAI_GPT_IMAGE_TIMEOUT_MS = 540000;
|
||||
const GRSAI_GPT_IMAGE_4K_TIMEOUT_MS = 570000;
|
||||
const GRSAI_GPT_IMAGE_TIMEOUT_MS = 12 * 60 * 1000;
|
||||
const GRSAI_GPT_IMAGE_4K_TIMEOUT_MS = 14 * 60 * 1000;
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, any> {
|
||||
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
||||
|
||||
@ -122,7 +122,7 @@ async function executeDirectAgentEnhanceJob(params: {
|
||||
messageId: params.messageId,
|
||||
sourceImageUrl: params.imageUrl,
|
||||
},
|
||||
timeoutMs: 8 * 60 * 1000,
|
||||
timeoutMs: 20 * 60 * 1000,
|
||||
headers: cookieHeader
|
||||
? {
|
||||
cookie: cookieHeader,
|
||||
|
||||
@ -1539,29 +1539,41 @@ export async function generateCanvasImage(
|
||||
await slot.release();
|
||||
}
|
||||
|
||||
await recordAiModelHealthFailure({
|
||||
model: selectedModel.model,
|
||||
provider,
|
||||
error: caughtError,
|
||||
context: debugLabel,
|
||||
elapsedMs: Date.now() - startedAt,
|
||||
metadata: {
|
||||
aspectRatio,
|
||||
imageSize,
|
||||
imageCount,
|
||||
requestedReferenceImageCount: normalizedReferenceImages.length,
|
||||
reachableReferenceImageCount: reachableReferenceImages.length,
|
||||
effectiveReferenceImageCount: effectiveReferenceImages.length,
|
||||
droppedReferenceImageCount: unreachableReferenceImages.length,
|
||||
...debugMeta,
|
||||
},
|
||||
}).catch((healthError) => {
|
||||
console.warn("[Canvas Generate Image] Record model health failure failed:", {
|
||||
const scaleAdjustRejected =
|
||||
caughtError instanceof ScaleAdjustOutputRejectedError;
|
||||
|
||||
if (scaleAdjustRejected) {
|
||||
console.info("[Canvas Generate Image] Skip model health failure for scale adjust rejection:", {
|
||||
debugLabel,
|
||||
selectedModelRef: selectedModel.model.id,
|
||||
selectedModelId: selectedModel.model.modelId,
|
||||
error: healthError instanceof Error ? healthError.message : String(healthError),
|
||||
error: caughtError instanceof Error ? caughtError.message : String(caughtError),
|
||||
});
|
||||
});
|
||||
} else {
|
||||
await recordAiModelHealthFailure({
|
||||
model: selectedModel.model,
|
||||
provider,
|
||||
error: caughtError,
|
||||
context: debugLabel,
|
||||
elapsedMs: Date.now() - startedAt,
|
||||
metadata: {
|
||||
aspectRatio,
|
||||
imageSize,
|
||||
imageCount,
|
||||
requestedReferenceImageCount: normalizedReferenceImages.length,
|
||||
reachableReferenceImageCount: reachableReferenceImages.length,
|
||||
effectiveReferenceImageCount: effectiveReferenceImages.length,
|
||||
droppedReferenceImageCount: unreachableReferenceImages.length,
|
||||
...debugMeta,
|
||||
},
|
||||
}).catch((healthError) => {
|
||||
console.warn("[Canvas Generate Image] Record model health failure failed:", {
|
||||
selectedModelRef: selectedModel.model.id,
|
||||
selectedModelId: selectedModel.model.modelId,
|
||||
error: healthError instanceof Error ? healthError.message : String(healthError),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const failedModelRefs = Array.from(
|
||||
new Set([
|
||||
@ -1573,8 +1585,6 @@ export async function generateCanvasImage(
|
||||
].filter(Boolean))
|
||||
);
|
||||
const allowFailover = request.allowFailover !== false;
|
||||
const scaleAdjustRejected =
|
||||
caughtError instanceof ScaleAdjustOutputRejectedError;
|
||||
const shouldFailover =
|
||||
shouldFailoverAiModelError(caughtError) ||
|
||||
scaleAdjustRejected ||
|
||||
|
||||
@ -119,7 +119,7 @@ export async function requestLongTaskResult(params: {
|
||||
pollingParams.set(key, String(value));
|
||||
}
|
||||
|
||||
const timeoutMs = Math.max(10_000, params.timeoutMs ?? 8 * 60 * 1000);
|
||||
const timeoutMs = Math.max(10_000, params.timeoutMs ?? 20 * 60 * 1000);
|
||||
const maxPollFailures = Math.max(1, params.maxPollFailures ?? 4);
|
||||
const startedAt = Date.now();
|
||||
let pollAfterMs = Math.max(800, Number(result?.pollAfterMs || 1500));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user