fix dead loop while network error (#77)

This commit is contained in:
Frank Yang
2023-02-18 17:13:23 +08:00
committed by GitHub
parent 67a43e6392
commit 133d2c9184

View File

@@ -7,7 +7,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io"
"net/http" "net/http"
) )
@@ -27,10 +26,8 @@ func (stream *CompletionStream) Recv() (response CompletionResponse, err error)
waitForData: waitForData:
line, err := stream.reader.ReadBytes('\n') line, err := stream.reader.ReadBytes('\n')
if err != nil { if err != nil {
if errors.Is(err, io.EOF) {
return return
} }
}
var headerData = []byte("data: ") var headerData = []byte("data: ")
line = bytes.TrimSpace(line) line = bytes.TrimSpace(line)