fix(adobe): poll until the genCtx deadline instead of a shorter hardcoded cap
pollImage/pollVideo capped themselves at 3min/10min while the caller's genCtx budget is 8min (image) / 12min (video), so slow-but-valid generations were killed early with 'adobe generation timed out'. Now the loop honors ctx.Err() and uses the full budget.
This commit is contained in:
@@ -532,10 +532,9 @@ func (c *Client) submitImage(ctx context.Context, sess *tlsSession, token, promp
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) pollImage(ctx context.Context, sess *tlsSession, token, pollURL string) (map[string]any, []byte, error) {
|
func (c *Client) pollImage(ctx context.Context, sess *tlsSession, token, pollURL string) (map[string]any, []byte, error) {
|
||||||
start := time.Now()
|
|
||||||
for {
|
for {
|
||||||
if time.Since(start) > 3*time.Minute {
|
if err := ctx.Err(); err != nil {
|
||||||
return nil, nil, errors.New("adobe generation timed out")
|
return nil, nil, fmt.Errorf("adobe generation timed out: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, pollURL, nil)
|
req, err := http.NewRequest(http.MethodGet, pollURL, nil)
|
||||||
@@ -712,10 +711,9 @@ func (c *Client) submitVideo(ctx context.Context, sess *tlsSession, token, endpo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) pollVideo(ctx context.Context, sess *tlsSession, token, pollURL string, downloadResult bool) (map[string]any, []byte, error) {
|
func (c *Client) pollVideo(ctx context.Context, sess *tlsSession, token, pollURL string, downloadResult bool) (map[string]any, []byte, error) {
|
||||||
start := time.Now()
|
|
||||||
for {
|
for {
|
||||||
if time.Since(start) > 10*time.Minute {
|
if err := ctx.Err(); err != nil {
|
||||||
return nil, nil, errors.New("adobe video generation timed out")
|
return nil, nil, fmt.Errorf("adobe video generation timed out: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, pollURL, nil)
|
req, err := http.NewRequest(http.MethodGet, pollURL, nil)
|
||||||
|
|||||||
Reference in New Issue
Block a user