Skip to content

fix: sse line endings#3686

Merged
mrlubos merged 1 commit into
mainfrom
refactor/sse-line-endings
Apr 5, 2026
Merged

fix: sse line endings#3686
mrlubos merged 1 commit into
mainfrom
refactor/sse-line-endings

Conversation

@mrlubos

@mrlubos mrlubos commented Apr 5, 2026

Copy link
Copy Markdown
Member

No description provided.

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@pullfrog

pullfrog Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Reviewed PR #3686. The regex simplification from .replace(/\r\n/g, '\n').replace(/\r/g, '\n') to .replace(/\r\n?/g, '\n') is semantically equivalent and correct. The remaining changes (arrow→function declaration, style normalization in tests, 280+ matching snapshot updates) are all consistent. No issues found.

Task list (5/5 completed)
  • Read diff TOC and identify high-risk areas of change
  • Review changesets and source code changes (non-snapshot)
  • Review SSE parser implementation and tests
  • Spot-check snapshot changes for consistency
  • Submit review

Pullfrog  | View workflow run | Triggered by Pullfrog𝕏

@changeset-bot

changeset-bot Bot commented Apr 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c9c1d44

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mrlubos mrlubos marked this pull request as ready for review April 5, 2026 23:28
@vercel

vercel Bot commented Apr 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hey-api-docs Ready Ready Preview, Comment Apr 5, 2026 11:28pm

Request Review

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug 🔥 Broken or incorrect behavior. labels Apr 5, 2026

@pullfrog pullfrog Bot 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.

Reviewed — no issues found.

Pullfrog  | View workflow run𝕏

@pullfrog

pullfrog Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

TL;DR — Simplifies SSE line-ending normalization from two chained .replace() calls to a single regex (/\r\n?/g), and converts createSseClient from an arrow function to a function declaration. Applied across all client plugins and regenerated snapshots.

Key changes

  • Simplify SSE line-ending normalization to a single regex — Replaces the two-pass replace(/\r\n/g, '\n').replace(/\r/g, '\n') with the equivalent single-pass replace(/\r\n?/g, '\n') in the serverSentEvents.ts bundle.
  • Convert createSseClient to a function declaration — Changes from export const createSseClient = <TData>(...) => { to export function createSseClient<TData>(...) {, aligning with standard function declaration style.
  • Minor lint fixes in tests — Updates any[] to Array<any> and string[] to ReadonlyArray<string> in serverSentEvents.test.ts.
  • Regenerated snapshots and examples — All 270+ serverSentEvents.gen.ts snapshot and example files updated to reflect the source changes.

Summary | 283 files | 1 commit | base: mainrefactor/sse-line-endings

This is a single-feature PR. The two-pass approach (\r\n\n, then \r\n) and the single-pass regex (\r\n?\n) are functionally identical — \r\n? matches \r\n (CRLF) first when followed by \n, and bare \r (CR) otherwise, covering all three line-ending styles in one pass.

Before: buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n'); with a separate comment line
After: buffer = buffer.replace(/\r\n?/g, '\n'); with an inline comment

Why does /\r\n?/g work as a single-pass replacement?

The regex \r\n? greedily matches \r followed by an optional \n. When the input contains \r\n (CRLF), the engine matches both characters and replaces them with \n. When it encounters a bare \r (old Mac-style CR), it matches just the \r and replaces it with \n. Lone \n characters are unaffected since \r is required. This is a well-known single-regex idiom for line-ending normalization.

serverSentEvents.ts · serverSentEvents.test.ts

Pullfrog  | View workflow run | Triggered by Pullfrog𝕏

@pkg-pr-new

pkg-pr-new Bot commented Apr 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@hey-api/codegen-core

npm i https://pkg.pr.new/@hey-api/codegen-core@3686

@hey-api/json-schema-ref-parser

npm i https://pkg.pr.new/@hey-api/json-schema-ref-parser@3686

@hey-api/nuxt

npm i https://pkg.pr.new/@hey-api/nuxt@3686

@hey-api/openapi-ts

npm i https://pkg.pr.new/@hey-api/openapi-ts@3686

@hey-api/shared

npm i https://pkg.pr.new/@hey-api/shared@3686

@hey-api/spec-types

npm i https://pkg.pr.new/@hey-api/spec-types@3686

@hey-api/types

npm i https://pkg.pr.new/@hey-api/types@3686

@hey-api/vite-plugin

npm i https://pkg.pr.new/@hey-api/vite-plugin@3686

commit: c9c1d44

@codecov

codecov Bot commented Apr 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 39.39%. Comparing base (8d3167c) to head (c9c1d44).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3686      +/-   ##
==========================================
- Coverage   39.39%   39.39%   -0.01%     
==========================================
  Files         520      520              
  Lines       19279    19278       -1     
  Branches     5714     5708       -6     
==========================================
- Hits         7595     7594       -1     
  Misses       9445     9445              
  Partials     2239     2239              
Flag Coverage Δ
unittests 39.39% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mrlubos mrlubos merged commit 79e7d3a into main Apr 5, 2026
12 checks passed
@mrlubos mrlubos deleted the refactor/sse-line-endings branch April 5, 2026 23:32
@hey-api hey-api Bot mentioned this pull request Apr 4, 2026
@hey-api hey-api Bot mentioned this pull request Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔥 Broken or incorrect behavior. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant