Skip to content

Commit

Permalink
fix: decrease oauth prompt timeout
Browse files Browse the repository at this point in the history
Decrease OAuth prompt timeout to 90 seconds (from 5 minutes) and improve
timeout message.

Signed-off-by: Nick Hale <[email protected]>
  • Loading branch information
njhale committed Dec 5, 2024
1 parent b13c3a8 commit 80c51d6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/invoke/invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,15 @@ func (i *Invoker) stream(ctx context.Context, c kclient.WithWatch, prevThreadNam
Time: types.NewTime(time.Now()),
Prompt: prompt,
})

var (
timeoutMsg = "timeout waiting for prompt response from user"
timeout = 5 * time.Minute
)
if len(frame.Prompt.Fields) == 0 {
// In this case, we're waiting for an OAuth prompt
timeoutMsg = "timeout waiting for oauth"
timeout = 90 * time.Second
err := i.gptClient.PromptResponse(runCtx, gptscript.PromptResponse{
ID: frame.Prompt.ID,
Responses: map[string]string{
Expand All @@ -924,8 +932,8 @@ func (i *Invoker) stream(ctx context.Context, c kclient.WithWatch, prevThreadNam
defer timoutCancel()
select {
case <-timeoutCtx.Done():
case <-time.After(5 * time.Minute):
cancelRun(fmt.Errorf("timeout waiting for prompt response from user"))
case <-time.After(timeout):
cancelRun(errors.New(timeoutMsg))
}
}()
}
Expand Down

0 comments on commit 80c51d6

Please sign in to comment.