-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the bug
After cancelling the context passed to CreateChatCompletionStream
, stream.Recv()
returns "error, " error. Debugging shows that it happens in these lines:
Lines 63 to 71 in c4273cb
for { | |
rawLine, readErr := stream.reader.ReadBytes('\n') | |
if readErr != nil || hasErrorPrefix { | |
respErr := stream.unmarshalError() | |
if respErr != nil { | |
return nil, fmt.Errorf("error, %w", respErr.Error) | |
} | |
return nil, readErr | |
} |
After cancellation rawLine, readErr := stream.reader.ReadBytes('\n')
returns io.EOF
error but then stream.unmarshalError()
returns *openai.ErrorResponse
that wraps *openai.APIError
which wraps nil
value.

Expected behavior
It should propagate io.EOF
properly
Screenshots/Logs
If applicable, add screenshots to help explain your problem. For non-graphical issues, please provide any relevant logs or stack traces.
Environment (please complete the following information):
- go-openai version: v1.40.1
- Go version: 1.24.5
- OpenAI API version: v1
- OS: macOS
Additional context
Add any other context about the problem here.