Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@csbzy
Copy link
Contributor

@csbzy csbzy commented Jul 22, 2025

@csbzy csbzy changed the title Fix sse timeout will effect by http.Server 's WriteTimeout Fix SSE timeout will effect by http.Server 's WriteTimeout Jul 22, 2025
@csbzy csbzy changed the title Fix SSE timeout will effect by http.Server 's WriteTimeout Fix SSE timeout will affected by http.Server 's WriteTimeout Jul 22, 2025
@kevwan kevwan requested a review from Copilot July 23, 2025 02:32
Copy link
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 fixes an issue where Server-Sent Events (SSE) connections are affected by the http.Server's WriteTimeout configuration. The solution prevents SSE connections from being terminated by write timeouts by disabling the write deadline for these specific connections.

  • Adds an Unwrap method to WithCodeResponseWriter to expose the underlying ResponseWriter
  • Implements write deadline clearing for SSE routes using http.NewResponseController

Reviewed Changes

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

File Description
rest/internal/response/withcoderesponsewriter.go Adds Unwrap method to expose underlying ResponseWriter for timeout control
rest/engine.go Implements SSE timeout fix by clearing write deadlines using ResponseController
Comments suppressed due to low confidence (1)

rest/engine.go:75

  • [nitpick] The error message on line 77 could be more descriptive. Consider changing 'set conn write deadline failed' to 'failed to clear write deadline for SSE connection' to better explain the context and purpose.
			err := rc.SetWriteDeadline(time.Time{})

@codecov
Copy link

codecov bot commented Jul 23, 2025

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rest/internal/response/withcoderesponsewriter.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@kevwan kevwan merged commit 0be63c3 into zeromicro:master Jul 23, 2025
5 of 6 checks passed
@kevwan kevwan mentioned this pull request Jul 23, 2025
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.

2 participants