Repository navigation
Conversation
…eams
openai-go v3.41.0 dispatches comment-only SSE blocks (e.g. ": keep-alive"
lines sent by proxies and OpenAI-compatible gateways) as events with empty
data. Stream.Next() then feeds the empty payload to json.Unmarshal, fails
with "unexpected end of JSON input", and aborts the response mid-stream.
Upstream fixed this in v3.43.0 ("ssestream: skip SSE blocks without
data", openai/openai-go#621, commit 114224d) by skipping blocks that
carried no data lines. Upgrade to the current v3.50.0 to pick it up.
No code changes required: the v3 API is backward compatible across this
range, and make test / make check pass unchanged.
|
✅ OpenCodeReview: Review skipped: no items were selected. |
|
This is covered by the dependabot weekly deps update: Pull Request 880 |
|
Happy either way — the reason this PR exists is the specific failure it fixes (SSE comment heartbeats aborting streams), not the bump itself. If #880 is the preferred vehicle I'll close this one; just worth a line there noting the openai-go bump fixes that bug, so the behavior change stays traceable. |
|
Closing as promised: #880 merged with openai-go v3.51.0, which covers the floor this PR targeted. For traceability — the load-bearing part of that batch for streaming is the openai-go bump; it's what stops SSE comment heartbeats from aborting streams, as described here. Thanks @stay-foolish-forever for the earlier review and @wu21-web for flagging the overlap. |
Description
Upgrades
github.com/openai/openai-go/v3from v3.41.0 to v3.50.0 (current latest) to pick up an upstream streaming fix. No code changes — the v3 API is backward compatible across this range.The problem this fixes: v3.41.0's SSE decoder dispatches comment-only SSE blocks as events with empty data. Many proxies and OpenAI-compatible gateways emit comment lines (e.g.
: keep-alive) as heartbeats during long generations. When one arrives:ssestream.Decoder.Next()dispatches an event whoseDatais empty (v3.41.0ssestream.gohas no empty-data guard),Stream.Next()passes that empty payload tojson.Unmarshal, which fails withunexpected end of JSON input,s.err), so the whole streaming response aborts mid-stream.Upstream fixed this in v3.43.0:
ssestream: skip SSE blocks without data(openai/openai-go#621) — blocks that carried no data lines are now skipped instead of dispatched.Behavioral change: none. Request and response wire formats are unchanged; the only observable difference is that streaming no longer errors out when a gateway sends comment heartbeats. The
go.moddiff beyond openai-go itself (gjson,golang.org/x/*) is exactly whatgo mod tidyrequires for the new SDK version.Split out of #806 so this uncontroversial dependency fix can be reviewed and merged independently of the replay design discussion there.
Type of Change
How Has This Been Tested?
make testpasses locally (all packages, zero code changes needed against the new SDK)make checkpasses locally (license headers,go mod tidy,gofmt,go vet)packages/ssestream/ssestream.gobetween v3.41.0 and v3.50.0: the only behavioral change is the addedif data.Len() == 0 { continue }guard at the event dispatch point.Checklist
go fmt,go vet)Related Issues
Related to #806 (split out of it; that PR will be rebased onto this once merged).