fix(rsplat): use fal.ai response_url for result fetch, add poll logging
The result fetch was constructing its own URL instead of using the response_url returned by fal.ai's status poll. This caused 422 errors. Now captures response_url from poll and uses it for result retrieval. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
97636235bf
commit
e5814b12c6
|
|
@ -790,6 +790,7 @@ async function process3DGenJob(job: Gen3DJob) {
|
||||||
|
|
||||||
// 3. Poll for completion (up to 8 min — Hunyuan3D with textures can take 3-5 min)
|
// 3. Poll for completion (up to 8 min — Hunyuan3D with textures can take 3-5 min)
|
||||||
const deadline = Date.now() + 480_000;
|
const deadline = Date.now() + 480_000;
|
||||||
|
let responseUrl = "";
|
||||||
let completed = false;
|
let completed = false;
|
||||||
while (Date.now() < deadline) {
|
while (Date.now() < deadline) {
|
||||||
await new Promise((r) => setTimeout(r, 3000));
|
await new Promise((r) => setTimeout(r, 3000));
|
||||||
|
|
@ -798,9 +799,11 @@ async function process3DGenJob(job: Gen3DJob) {
|
||||||
{ headers: falHeaders },
|
{ headers: falHeaders },
|
||||||
);
|
);
|
||||||
if (!statusRes.ok) continue;
|
if (!statusRes.ok) continue;
|
||||||
const status = await statusRes.json() as { status: string };
|
const statusData = await statusRes.json() as { status: string; response_url?: string };
|
||||||
if (status.status === "COMPLETED") { completed = true; break; }
|
console.log(`[3d-gen] Poll ${job.id}: status=${statusData.status}`);
|
||||||
if (status.status === "FAILED") {
|
if (statusData.response_url) responseUrl = statusData.response_url;
|
||||||
|
if (statusData.status === "COMPLETED") { completed = true; break; }
|
||||||
|
if (statusData.status === "FAILED") {
|
||||||
job.status = "failed";
|
job.status = "failed";
|
||||||
job.error = "3D generation failed on fal.ai";
|
job.error = "3D generation failed on fal.ai";
|
||||||
job.completedAt = Date.now();
|
job.completedAt = Date.now();
|
||||||
|
|
@ -814,20 +817,16 @@ async function process3DGenJob(job: Gen3DJob) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Fetch result (retry once after 3s on transient failure)
|
// 4. Fetch result using response_url from status (with fallback)
|
||||||
let resultRes = await fetch(
|
const resultUrl = responseUrl || `https://queue.fal.run/${MODEL}/requests/${request_id}`;
|
||||||
`https://queue.fal.run/${MODEL}/requests/${request_id}`,
|
console.log(`[3d-gen] Fetching result from: ${resultUrl}`);
|
||||||
{ headers: falHeaders },
|
let resultRes = await fetch(resultUrl, { headers: falHeaders });
|
||||||
);
|
|
||||||
if (!resultRes.ok) {
|
if (!resultRes.ok) {
|
||||||
console.warn(`[3d-gen] Result fetch failed (status=${resultRes.status}), retrying in 3s...`);
|
console.warn(`[3d-gen] Result fetch failed (status=${resultRes.status}), retrying in 3s...`);
|
||||||
const errBody = await resultRes.text().catch(() => "");
|
const errBody = await resultRes.text().catch(() => "");
|
||||||
console.warn(`[3d-gen] Result error body:`, errBody);
|
console.warn(`[3d-gen] Result error body:`, errBody);
|
||||||
await new Promise((r) => setTimeout(r, 3000));
|
await new Promise((r) => setTimeout(r, 3000));
|
||||||
resultRes = await fetch(
|
resultRes = await fetch(resultUrl, { headers: falHeaders });
|
||||||
`https://queue.fal.run/${MODEL}/requests/${request_id}`,
|
|
||||||
{ headers: falHeaders },
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (!resultRes.ok) {
|
if (!resultRes.ok) {
|
||||||
const errBody = await resultRes.text().catch(() => "");
|
const errBody = await resultRes.text().catch(() => "");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue