Repository navigation
fix(streaming): emit terminal SSE events missing a trailing blank line - #2726
Conversation
Flush the SSE decoder at EOF so a final data: line without \n\n is delivered exactly once instead of being dropped. Fixes openai#2725.
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Reviewed with Codex at 1d4018d9619b2b9f615b42d55b64572dec96ed6f. EOF flushing matches the behavior requested in #2725. Traced line decoding, abort handling, source disposal, completed-event deduplication, comment trailers, and [DONE] handling. No actionable correctness or compatibility findings. LGTM.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Castiron custom code✅ No new custom-code files detected. 45 mixed files remain; 0 existing customizations changed. Compared 45 existing customizations unchanged
5 more in the full report. A changed generated baseline means this report cannot reliably identify which handwritten lines changed. Inspect the custom-code diffDownload the exact patch produced by this run (requires repository access): gh run download 35122812022 --repo openai/openai-node \
--name castiron-custom-code-35122812022-1 --dir /tmp/castiron-custom-code-35122812022-1
git apply --stat /tmp/castiron-custom-code-35122812022-1/custom-code.patch
cat /tmp/castiron-custom-code-35122812022-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin eda4d0cd54271ac9fc05a3e44dfe7fd1c16d2d77 c0e44df8b1ba23c2982b248bd4db81f8972b8084
python3 scripts/castiron/custom_code_report.py report \
--base eda4d0cd54271ac9fc05a3e44dfe7fd1c16d2d77 \
--head c0e44df8b1ba23c2982b248bd4db81f8972b8084 --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-c0e44df8b1ba
cat /tmp/castiron-custom-code-c0e44df8b1ba/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
Automated Release PR --- ## [7.17.0](v7.16.0...v7.17.0) (2026-09-16) ### Features * **api:** add compaction progress events ([#2749](#2749)) ([425502d](425502d)) ### Bug Fixes * **ci:** retry transient Deno download failures ([#2752](#2752)) ([e39037b](e39037b)) * preserve chat runner abort reasons ([#2607](#2607)) ([eda4d0c](eda4d0c)) * **realtime:** preserve native WebSocket error causes ([#2715](#2715)) ([58fa72a](58fa72a)) * **responses:** reject function-based API keys in WebSocket constructors ([#2586](#2586)) ([eea7618](eea7618)) * **runners:** reject unfinished turns in streaming runTools ([#2716](#2716)) ([937ed67](937ed67)) * **streaming:** emit terminal SSE events missing a trailing blank line ([#2726](#2726)) ([94d6418](94d6418)) * **zod:** omit impossible optional branch in strict schemas ([#2751](#2751)) ([2b4c2c7](2b4c2c7)) ### Chores * update lint tooling and tailor anti-slop for the SDK ([#2753](#2753)) ([21a03c2](21a03c2)) ### Documentation * **examples:** preserve split UTF-8 in raw stream consumer ([#2714](#2714)) ([f44152a](f44152a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
Summary
SSEDecoderpreviously emitted only on a blank line.iterSSEChunksalready yields leftover bytes at EOF andLineDecoderis flushed, but the SSE decoder was never flushed, so a finaldata:/event:record without\n\nwas discarded.finish_reason/response.completedare delivered when a gateway closes the stream immediately after the last field.flush()returnsnullwhen no event is in progress, so there is no double-emit. Comment-only trailers still produce no event. Abort still returns before flush.Fixes #2725.
Test plan
./scripts/test tests/lib/streaming-core.test.ts tests/streaming.test.ts(86 passed)./scripts/test tests/lib/streaming-named-error-events.test.ts tests/lib/streaming-sentinel-integrity.test.ts tests/lib/streaming-malformed-sse-privacy.test.ts tests/core/streaming-backpressure.test.ts tests/core/streaming-large-events.test.ts tests/core/streaming-security.test.ts(98 passed)\n\n, single\n/\r/\r\n, no final newline, multi-event, comment-only trailer, and abort mid-stream