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 4, 2024
1 parent 787f4cc commit 7c2b24c
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 @@ -901,7 +901,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 @@ -918,8 +926,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 7c2b24c

Please sign in to comment.