Skip to content

Reset SSE parser metadata state - #1069

Open
PeterDaveHello wants to merge 1 commit into
ChatGPTBox-dev:masterfrom
PeterDaveHello:fix/sse-reset-clears-extra
Open

Reset SSE parser metadata state#1069
PeterDaveHello wants to merge 1 commit into
ChatGPTBox-dev:masterfrom
PeterDaveHello:fix/sse-reset-clears-extra

Conversation

@PeterDaveHello

@PeterDaveHello PeterDaveHello commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Clear pending extra metadata when createParser().reset() is called.
  • Add a regression test that feeds meta state, resets the parser, and verifies the next event does not inherit stale metadata.

Why

reset() already clears the decoder, text buffer, event ID, event name, data, and CRLF state, but it leaves extra untouched. If reset() is called after a parsed meta: line but before the event is dispatched, that stale metadata can leak into the next event.

This keeps reset() semantics consistent across all parser state without changing normal event parsing.

Summary by CodeRabbit

  • Bug Fixes

    • Resetting the event parser now clears pending event metadata, preventing stale metadata from appearing in subsequent events.
  • Tests

    • Added coverage verifying that reset operations emit later events without previously stored metadata.

Copilot AI lite review requested due to automatic review settings September 11, 2026 19:15
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 82ae09c8-5db6-486c-97d9-f6906cbdbdd8

📥 Commits

Reviewing files that changed from the base of the PR and between fa93eac and 8394cea.

📒 Files selected for processing (2)
  • src/utils/eventsource-parser.mjs
  • tests/unit/utils/eventsource-parser.test.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The parser reset now clears pending extra metadata. A unit test verifies that a subsequent event emits with extra set to undefined.

Changes

Parser reset behavior

Layer / File(s) Summary
Reset metadata and validation
src/utils/eventsource-parser.mjs, tests/unit/utils/eventsource-parser.test.mjs
createParser.reset() clears extra. The test confirms that metadata from a previous event is not emitted after reset.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 8394c

The parser now clears pending metadata on reset, with focused test coverage and no remaining merge-blocking concerns.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: resetting SSE parser metadata state.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Reset SSE metadata during parser reset

🐞 Bug fix 🧪 Tests 🕐 Less than 10 minutes

Grey Divider

AI Description

• Clear pending SSE metadata whenever parser state is reset.
• Prevent post-reset events from inheriting metadata parsed before reset.
• Add regression coverage for metadata isolation across reset boundaries.
Diagram

graph TD
  A["Meta line"] -->|stores metadata| B["Pending state"] -->|reset| C["Clean state"] -->|receives| D["Data line"] -->|dispatches| E["SSE event"]
Loading
High-Level Assessment

Clearing extra alongside the parser’s existing reset fields is the safest and most consistent approach. Recreating the parser or restructuring all state into a separate object would add unnecessary complexity for this isolated omission.

Files changed (2) +20 / -0

Bug fix (1) +1 / -0
eventsource-parser.mjsClear pending metadata during parser reset +1/-0

Clear pending metadata during parser reset

• Adds 'extra' to the state cleared by 'reset()', preventing metadata parsed before reset from leaking into later events.

src/utils/eventsource-parser.mjs

Tests (1) +19 / -0
eventsource-parser.test.mjsCover metadata isolation across parser resets +19/-0

Cover metadata isolation across parser resets

• Adds a regression test that feeds metadata, resets the parser, and verifies the next data event has no stale 'extra' value.

tests/unit/utils/eventsource-parser.test.mjs

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The fix includes regression coverage and no blocking issues were identified.

Pull request overview

Resets pending SSE parser metadata to prevent stale values from leaking into subsequent events.

Changes:

  • Clears extra metadata during parser reset.
  • Adds regression coverage for reset behavior.
File summaries
File Description
tests/unit/utils/eventsource-parser.test.mjs Verifies metadata is discarded after reset.
src/utils/eventsource-parser.mjs Clears pending metadata during reset.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • src/utils/eventsource-parser.mjs — added extra = void 0 to createParser().reset() so a pending meta: payload is cleared alongside the rest of the parser state, completing the reset for every state field.
  • tests/unit/utils/eventsource-parser.test.mjs — new regression test that feeds a meta: line, resets the parser, feeds data:, and asserts the next event carries no leftover extra.

ℹ️ Scope note: the leak is latent today

reset() has no production callers — the sole consumer of createParser, src/utils/fetch-sse.mjs:88, creates one parser per request and never invokes reset(). The extra/meta field is also unused downstream (fetch-sse.mjs:89-92 forwards only event.data to onMessage). So this is a consistency/correctness fix for the exported parser API rather than a change to shipped stream behavior. That said, the fix and test are both correct: I confirmed locally that removing the extra = void 0 line makes the new test fail (suite goes 23/24) and restoring it brings the suite back to 24/24.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants