Skip to content

🐛 bug: remove SSE Next and clarify SSE handler docs#4247

Merged
ReneWerner87 merged 16 commits into
mainfrom
copilot/task-59947262-234231371-28eee08f-dc9c-42ea-a892-cec7cfab0cc3
May 2, 2026
Merged

🐛 bug: remove SSE Next and clarify SSE handler docs#4247
ReneWerner87 merged 16 commits into
mainfrom
copilot/task-59947262-234231371-28eee08f-dc9c-42ea-a892-cec7cfab0cc3

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

Description

This PR removes the SSE Next skip hook so the package behaves as a terminal SSE route handler, updates the interrupted-client test to use fiber.TestConfig, and clarifies the SSE documentation to match the current API.

The changes keep the SSE package focused on stream transport behavior, make the disconnect test use Fiber’s supported test path, and document that Config.Handler is required because sse.New() panics when it is omitted or nil.

Changes introduced

  • Benchmarks: No benchmark changes were needed for this update.
  • Documentation Update: Updated /docs/middleware/sse.md to use handler terminology consistently and to document that Config.Handler is required and sse.New() panics when it is nil.
  • Changelog/What's New: No changelog entry was added.
  • Migration Guide: No migration guide was added.
  • API Alignment with Express: No Express alignment changes were introduced.
  • API Longevity: Removed the Next skip hook from the public SSE config and clarified the required Handler contract to make the API behavior more explicit and less error-prone.
  • Examples: The SSE documentation examples continue to show the required Handler usage, and the disconnect coverage now uses fiber.TestConfig{FailOnTimeout: false, Timeout: time.Second} in middleware/sse/sse_test.go.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Enhancement (improvement to existing features and functionality)
  • Documentation update (changes to documentation)
  • Performance improvement (non-breaking change which improves efficiency)
  • Code consistency (non-breaking change which improves code reliability and robustness)

Checklist

Before you submit your pull request, please make sure you meet these requirements:

  • Followed the inspiration of the Express.js framework for new functionalities, making them similar in usage.
  • Conducted a self-review of the code and provided comments for complex or critical parts.
  • Updated the documentation in the /docs/ directory for Fiber's documentation.
  • Added or updated unit tests to validate the effectiveness of the changes or new features.
  • Ensured that new and existing unit tests pass locally with the changes.
  • Verified that any new dependencies are essential and have been agreed upon by the maintainers/community.
  • Aimed for optimal performance with minimal allocations in the new code.
  • Provided benchmarks for the new code to analyze and improve upon.

Commit formatting

Please use emojis in commit messages for an easy way to identify the purpose or intention of a commit. Check out the emoji cheatsheet here: CONTRIBUTING.md

Copilot AI and others added 8 commits April 30, 2026 12:59
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.23%. Comparing base (fbc03bd) to head (e1d7123).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4247      +/-   ##
==========================================
- Coverage   91.23%   91.23%   -0.01%     
==========================================
  Files         126      126              
  Lines       12341    12339       -2     
==========================================
- Hits        11259    11257       -2     
  Misses        678      678              
  Partials      404      404              
Flag Coverage Δ
unittests 91.23% <ø> (-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.

Comment thread middleware/sse/sse_test.go
Copilot finished work on behalf of gaby May 1, 2026 12:04
Copilot AI requested a review from gaby May 1, 2026 12:04
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: f362b3a Previous: 2b45a43 Ratio
Benchmark_Compress/Zstd (github.com/gofiber/fiber/v3/middleware/compress) - B/op 1 B/op 0 B/op +∞

This comment was automatically generated by workflow using github-action-benchmark.

@gaby gaby moved this to In Progress in v3 May 1, 2026
@gaby gaby marked this pull request as ready for review May 1, 2026 23:24
@gaby gaby requested a review from a team as a code owner May 1, 2026 23:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the SSE middleware package to behave and be described as a terminal SSE route handler, removing the Next/skip hook and improving the disconnect test to more reliably simulate client interruption via fiber.TestConfig timeouts.

Changes:

  • Removed Config.Next and the c.Next() skip path from sse.New().
  • Updated SSE docs to remove the Next option from the config table/default config.
  • Replaced the Next-skipping test with a timeout-driven interrupted-client test that asserts the stream observes disconnect and OnClose is invoked with an error.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
middleware/sse/sse_test.go Reworks the disconnect test to use fiber.TestConfig timeouts and validate Done()/Err()/OnClose behavior.
middleware/sse/sse.go Removes Next handling and updates package/API wording toward “handler”.
middleware/sse/config.go Removes Next from the public config surface and default config.
docs/middleware/sse.md Updates documented config surface/default config to match removal of Next.
Comments suppressed due to low confidence (2)

middleware/sse/sse.go:6

  • The package-level docs still say "core middleware" (line 6), but this PR renames the package and New() docs to use "handler" terminology. Please update the remaining references in this comment block so the package description is internally consistent (e.g., change "core middleware" to "core handler" or similar).
// The package focuses on the SSE transport: response headers, wire formatting,
// flushing, heartbeat comments, and disconnect detection via flush errors.
// Application-specific concerns such as topics, replay storage, authentication,
// and pub/sub fan-out intentionally stay outside the core middleware.

middleware/sse/config.go:18

  • Removing the exported Config.Next field is a breaking API change for users configuring SSE. Please add an explicit migration note (e.g., in the release notes / whats_new) stating that SSE no longer supports Next/skip semantics and must be mounted as a route handler (or use the dedicated skip middleware upstream).
type Config struct {
	// Handler writes events to the stream.
	//
	// Required.
	Handler Handler

Comment thread middleware/sse/config.go Outdated
Comment thread docs/middleware/sse.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI changed the title 🐛 bug: remove SSE Next and clarify middleware docs 🐛 bug: remove SSE Next and clarify SSE handler docs May 2, 2026
Copilot finished work on behalf of gaby May 2, 2026 13:44
@ReneWerner87 ReneWerner87 merged commit dd8ec01 into main May 2, 2026
21 checks passed
@ReneWerner87 ReneWerner87 deleted the copilot/task-59947262-234231371-28eee08f-dc9c-42ea-a892-cec7cfab0cc3 branch May 2, 2026 14:31
@github-project-automation github-project-automation Bot moved this from In Progress to Done in v3 May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants