Skip to content

Commit

Permalink
chore: add panic recover for openai component
Browse files Browse the repository at this point in the history
  • Loading branch information
donch1989 committed Aug 31, 2024
1 parent 6f1faa8 commit ae8db60
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ai/openai/v0/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,13 @@ type workerResult struct {
}

func (e *execution) worker(ctx context.Context, client *httpclient.Client, batchIdx int, input *structpb.Struct, result chan<- *workerResult) {
defer func() { result <- &workerResult{done: true} }()
defer func() {
if r := recover(); r != nil {
fmt.Printf("panic: %+v", r)
result <- &workerResult{batchIdx: batchIdx, err: fmt.Errorf("panic: %+v", r)}
}
result <- &workerResult{done: true}
}()

switch e.Task {
case TextGenerationTask:
Expand Down

0 comments on commit ae8db60

Please sign in to comment.