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,9 +26,7 @@ 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: ")