fix: resume transient original-job collection and guard probe input
This commit is contained in:
@@ -80,6 +80,7 @@ export class ImageVideoService {
|
||||
if (r.state === "unknown_submission" || r.state === "ready" || r.state === "failed" || Date.now() - (r.lastPollAt ?? 0) < 30_000) return this.public(r);
|
||||
if (!r.jobId && !(r.upload && ["importing", "unknown_upload"].includes(r.state))) return this.public(r);
|
||||
r.lastPollAt = Date.now(); await this.save(r);
|
||||
let collecting = false;
|
||||
try {
|
||||
if (!r.jobId) {
|
||||
const result = await this.options.remote.importStatus(r);
|
||||
@@ -90,14 +91,16 @@ export class ImageVideoService {
|
||||
if (result.state === "succeeded") {
|
||||
if (!result.artifactUrl) throw new Error("No unambiguous MP4 artifact");
|
||||
r.artifactUrl = result.artifactUrl; r.state = "validating"; await this.save(r);
|
||||
collecting = true;
|
||||
r.validation = validationSchema.parse(await this.options.collect(result.artifactUrl, join(this.root, id), r.draft.durationSeconds));
|
||||
if (Math.abs(r.validation.videoSeconds - r.draft.durationSeconds) > 0.002 || Math.abs(r.validation.audioSeconds - r.draft.durationSeconds) > 0.05) throw new Error("Duration mismatch");
|
||||
r.state = "ready"; delete r.error;
|
||||
} else { r.state = result.state; if (result.state === "failed") r.error = "H3 生成失败;未自动重投。"; }
|
||||
}
|
||||
} catch {
|
||||
if (r.state === "validating") r.state = "failed";
|
||||
r.error = r.state === "failed" ? "成片技术验证失败:请核实 MP4、精确时长、尺寸、帧率和音轨;未自动重投。" : "状态响应暂不可用或契约不明确;保留原任务,下次只读查询。";
|
||||
} catch (error) {
|
||||
const retryCollection = collecting && error instanceof HarnessError && error.code === "I2V_TRANSFER_TRANSIENT";
|
||||
if (collecting && !retryCollection) r.state = "failed";
|
||||
r.error = retryCollection ? "成片收取暂时失败;30 秒后查询原任务并重试收取,不会重新生成。" : r.state === "failed" ? "成片技术验证失败:请核实 MP4、精确时长、尺寸、帧率和音轨;未自动重投。" : "状态响应暂不可用或契约不明确;保留原任务,下次只读查询。";
|
||||
}
|
||||
await this.save(r); return this.public(r);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user