Skip to content

Conversation

@unnoq
Copy link
Member

@unnoq unnoq commented Jan 13, 2026

Related: https://discordapp.com/channels/1308966753044398161/1308971636539658260/1460548346702987358

Summary by CodeRabbit

  • Bug Fixes

    • Fixed event parser to properly handle events split across multiple data chunks, ensuring incomplete message fragments are retained until complete event assembly.
  • Tests

    • Restructured decoder tests to validate mixed chunk scenarios and event parsing across multiple feeds.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

The EventDecoder now persists incomplete data across feed calls instead of clearing it after processing. Tests were restructured to verify mixed-chunk scenarios where events split non-atomically across feeds, with adjusted expectations for field values based on chunk boundaries.

Changes

Cohort / File(s) Summary
Decoder Implementation
packages/standard-server/src/event-iterator/decoder.ts
Removed the reset of this.incomplete at the end of feed(), allowing incomplete message data to persist across multiple feed calls for proper reconstruction of split events.
Decoder Tests
packages/standard-server/src/event-iterator/decoder.test.ts
Restructured test to feed mixed chunk sequences across multiple feeds; renamed to reflect mixed-chunk scenario; updated expectations to show undefined id/retry in early events and defined values only after later chunks complete the message.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

Poem

🐰 A rabbit hops through streaming threads,
No longer clearing what's not said—
Chunks persist through every feed,
Events split, then fulfilled indeed! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: decoding chunks in http event stream' directly relates to the main change: modifying EventDecoder to persist incomplete data across feed calls, fixing chunk handling in HTTP event streams.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95c582a and fd51185.

📒 Files selected for processing (2)
  • packages/standard-server/src/event-iterator/decoder.test.ts
  • packages/standard-server/src/event-iterator/decoder.ts
💤 Files with no reviewable changes (1)
  • packages/standard-server/src/event-iterator/decoder.ts
🧰 Additional context used
🧬 Code graph analysis (1)
packages/standard-server/src/event-iterator/decoder.test.ts (1)
packages/standard-server/src/event-iterator/decoder.ts (1)
  • EventDecoder (56-88)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test
  • GitHub Check: publish-commit
  • GitHub Check: lint
🔇 Additional comments (2)
packages/standard-server/src/event-iterator/decoder.test.ts (2)

87-140: LGTM! Comprehensive test for chunked event stream decoding.

The test correctly exercises the decoder's ability to handle:

  • Events split across multiple feed() calls (lines 92-94)
  • Complete events in a single feed (line 96)
  • A chunk containing 1.5 events where an event boundary falls mid-chunk (line 98)
  • Continuation of partial events with id/retry fields (line 99)
  • Final termination with just a newline (line 100)

The comment at line 97-98 is helpful for maintainers. The expectations correctly reflect that id and retry are only present on events 4 and 5 where those fields were actually included in the event data.


163-219: Good coverage of stream-based mixed chunk handling.

The test at lines 169-172 specifically validates that events split across multiple stream chunks are correctly reassembled:

controller.enqueue('event: done\n')
controller.enqueue('data: hello4\n')
controller.enqueue('data: world\n\n')

The expected result correctly shows id: undefined and retry: undefined for this event since those fields weren't included in the streamed chunks.


Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue in the HTTP event stream decoder where fragmented event messages were not being correctly processed. By adjusting the buffer management and introducing comprehensive tests for mixed-chunk scenarios, the decoder now reliably reconstructs and emits events even when they arrive in incomplete or interleaved segments, leading to more stable and accurate event stream handling.

Highlights

  • Event Stream Decoding Fix: The EventDecoder logic has been refined to correctly handle fragmented HTTP event stream chunks, ensuring that partial messages are properly buffered and processed across multiple feed calls.
  • Improved Test Coverage: New and updated unit tests have been introduced to cover complex scenarios involving mixed and fragmented event data, significantly enhancing the robustness of the event stream decoder.
  • Buffer Management Correction: The incomplete buffer within the EventDecoder is no longer fully cleared after each processBuffer call, allowing incomplete event messages to persist and be completed by subsequent data chunks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively fixes a bug in the EventDecoder where partial event stream messages at the end of a data chunk were being discarded. The fix correctly preserves the incomplete message part for subsequent data chunks. The accompanying test has been significantly improved to cover various chunking scenarios, including fragmented messages and chunks containing multiple messages, which makes the decoder more robust. The changes are correct and improve the reliability of event stream parsing.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 13, 2026

More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@1356

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@1356

@orpc/client

npm i https://pkg.pr.new/@orpc/client@1356

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@1356

@orpc/experimental-durable-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-iterator@1356

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@1356

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@1356

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@1356

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@1356

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@1356

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@1356

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@1356

@orpc/experimental-pino

npm i https://pkg.pr.new/@orpc/experimental-pino@1356

@orpc/experimental-publisher

npm i https://pkg.pr.new/@orpc/experimental-publisher@1356

@orpc/experimental-publisher-durable-object

npm i https://pkg.pr.new/@orpc/experimental-publisher-durable-object@1356

@orpc/experimental-ratelimit

npm i https://pkg.pr.new/@orpc/experimental-ratelimit@1356

@orpc/react

npm i https://pkg.pr.new/@orpc/react@1356

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@1356

@orpc/experimental-react-swr

npm i https://pkg.pr.new/@orpc/experimental-react-swr@1356

@orpc/server

npm i https://pkg.pr.new/@orpc/server@1356

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@1356

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@1356

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@1356

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@1356

@orpc/standard-server-fastify

npm i https://pkg.pr.new/@orpc/standard-server-fastify@1356

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@1356

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@1356

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@1356

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@1356

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@1356

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@1356

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@1356

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@1356

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@1356

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@1356

commit: fd51185

@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@unnoq unnoq merged commit da9af8b into middleapi:main Jan 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant