Toggle navigation
Toggle navigation
This project
Loading...
Sign in
卢阳
/
front_backend_zImage
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
ly0303521
2026-01-09 14:42:20 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
823386d7c7d7d7df94f2c39a5b4ab2421d0e9dfe
823386d7
1 parent
f78d7c06
添加视频生成状态超时处理,限制处理时间为8分钟
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
z-image-generator/services/videoService.ts
z-image-generator/services/videoService.ts
View file @
823386d
...
...
@@ -36,6 +36,9 @@ export const pollVideoStatus = (
onStatusUpdate
:
(
status
:
VideoStatus
)
=>
void
)
:
Promise
<
VideoStatus
>
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
processingStartTime
:
number
|
null
=
null
;
const
PROCESSING_TIMEOUT_MS
=
8
*
60
*
1000
;
// 8 minutes limit for processing
const
interval
=
setInterval
(
async
()
=>
{
try
{
const
res
=
await
fetch
(
`
$
{
TURBO_DIFFUSION_API_URL
}
/status/
$
{
taskId
}
`
);
...
...
@@ -49,6 +52,17 @@ export const pollVideoStatus = (
const
data
:
VideoStatus
=
await
res
.
json
();
onStatusUpdate
(
data
);
// Track processing time
if
(
data
.
status
===
'processing'
)
{
if
(
processingStartTime
===
null
)
{
processingStartTime
=
Date
.
now
();
}
else
if
(
Date
.
now
()
-
processingStartTime
>
PROCESSING_TIMEOUT_MS
)
{
clearInterval
(
interval
);
reject
(
new
Error
(
"Video generation timed out (8 minutes processing limit)."
));
return
;
}
}
if
(
data
.
status
===
'complete'
||
data
.
status
===
'failed'
)
{
clearInterval
(
interval
);
if
(
data
.
status
===
'failed'
)
{
...
...
@@ -58,9 +72,8 @@ export const pollVideoStatus = (
}
}
}
catch
(
error
)
{
clearInterval
(
interval
);
console
.
error
(
'Polling error:'
,
error
);
reject
(
error
);
// Don't stop polling on transient network errors
console
.
warn
(
'Polling transient error:'
,
error
);
}
},
2000
);
// Poll every 2 seconds
});
...
...
Please
register
or
login
to post a comment