Skip to content

Conversation

wuqinqiang
Copy link
Contributor

#5155
#5094

When using rest.WithSSE() with timeout middleware enabled and clients not sending "Accept: text/event-stream" header,
so
https://github.com/zeromicro/go-zero/blob/master/rest/handler/timeouthandler.go#L63

SetWriteDeadline fails on timeoutWriter which doesn't implement the SetWriteDeadline interface.

This error is expected behavior and doesn't affect SSE functionality:

  • SSE still works correctly without clearing write deadline
  • timeoutWriter wraps ResponseWriter when timeout middleware is active
  • Error occurs when clients don't set proper Accept header

The error should be logged at debug level instead of error level to
avoid confusing users who see "feature not supported" errors that
don't actually indicate a problem.

Copy link

codecov bot commented Sep 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kevwan kevwan requested a review from Copilot September 9, 2025 13:57
@kevwan kevwan self-assigned this Sep 9, 2025
Copy link
Contributor

@Copilot 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 a logging issue in the Server-Sent Events (SSE) functionality where an expected error was being logged at error level instead of debug level. When timeout middleware is enabled and clients don't send the proper Accept header, the SetWriteDeadline method fails on timeoutWriter implementations, which is expected behavior that doesn't affect SSE functionality.

  • Changes error log to debug level for SetWriteDeadline failures in SSE connections
  • Adds explanatory comment about why this error is expected and harmless
  • Improves user experience by reducing confusing error messages

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@kevwan kevwan added this pull request to the merge queue Sep 27, 2025
Merged via the queue into zeromicro:master with commit cf55a88 Sep 27, 2025
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.

SSE set conn write deadline failed: feature not supported
2 participants